-
Notifications
You must be signed in to change notification settings - Fork 6
154 lines (128 loc) · 4.87 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Test
# Limited unit testing of the actions
on:
pull_request:
jobs:
test-main:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Style test
run: npx eslint .
- name: Check that cylc-action-utils.js was not wiped out
run: |
if [[ ! -f node_modules/cylc-action-utils.js ]]; then
echo "::error::node_modules/cylc-action-utils.js not found - do not let npm wipe it out"
exit 1
fi
- name: Other setup
run: echo ".github/test_bin" >> $GITHUB_PATH
- name: Test "cmp_py_versions"
run: |
assert_equal "$( ./bin/cmp_py_versions '8.0.0' '8' )" ""
assert_equal "$( ./bin/cmp_py_versions '8.0a3' '8.0.1' )" "8.0a3 not equal to 8.0.1"
if [[ $( ./bin/cmp_py_versions "8.O.1" "8.O.1" 2> out.stderr ) ]]; then
echo "::error:: Invalid version number 8.O.1 did not throw error"
exit 1
fi
exact_grep "InvalidVersion" out.stderr
- name: Run "configure-git"
uses: ./configure-git
- name: Test "configure-git"
run: |
echo "Somehow, Palpatine returned" >> README.md
# If configure-git didn't work, commit will fail:
git commit -a -m "Test commit"
test-stage-1:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
project-file: ['setup.py', 'setup.cfg', 'pyproject.toml']
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Other setup
run: echo ".github/test_bin" >> $GITHUB_PATH
- name: Run "sanitize-inputs"
uses: ./stage-1/sanitize-inputs
with:
version: ' 9.2.3 '
branch: " master "
- name: Test "sanitize-inputs" result
run: |
assert_equal "$VERSION" '9.2.3'
assert_equal "$BASE_REF" 'master'
- name: Run "checkout-pr-branch"
uses: ./stage-1/checkout-pr-branch
- name: Test "checkout-pr-branch" result
run: |
assert_equal "$HEAD_REF" 'prepare-9.2.3'
assert_equal "$( git branch --show-current )" 'prepare-9.2.3'
- name: Setup mock project files
run: |
cp .github/test_files/__init__.py ./__init__.py
cp .github/test_files/CHANGES.md ./CHANGES.md
cp .github/test_files/${{ matrix.project-file }} ./${{ matrix.project-file }}
echo "[command]git add ."; git add .
echo "[command]git commit"
git commit -m "Setup test files"
- name: Run "set-python-package-version"
id: set-package-version
uses: ./stage-1/set-python-package-version
with:
# Note this will check the published versions of the old isodatetime package on PyPI.
# The choice of package to check is arbitrary for this test, as long as it doesn't have a version 9.2.3
pypi-package-name: 'isodatetime'
init-file: '__init__.py'
- name: Test "set-python-package-version" result
run: |
python -c "
from __init__ import __version__
assert __version__ == '9.2.3', f'::error:: assert version {__version__} == 9.2.3'
"
package_version='${{ steps.set-package-version.outputs.package-version }}'
assert_equal "$package_version" "1!9.2.3"
# Check changes to init file are staged
exact_grep "M __init__.py" <(git status -s)
- name: Run "update-changelog-release-date"
uses: ./stage-1/update-changelog-release-date
with:
changelog-file: CHANGES.md
- name: Test "update-changelog-release-date" result
run: |
date_now=$( date '+%Y-%m-%d' --utc )
exact_grep "## isodatetime 2.1.0 (<span actions:bind='release-date'>Released $date_now</span>)" CHANGES.md
# Check only the topmost entry above had its date updated
exact_grep "## isodatetime 2.0.2 (<span actions:bind='release-date'>Released 2020-07-01</span>)" CHANGES.md
# Check changes to changelog are staged
exact_grep "M CHANGES.md" <(git status -s)
test-set-meta-releases:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: run
id: test-set-meta-releases
uses: ./set-meta-releases
- name: check
shell: python
run: |
import json
meta_releases_list = json.loads('${{ steps.test-set-meta-releases.outputs.meta-releases }}')
assert isinstance(meta_releases_list, list)
assert len(meta_releases_list) > 0
meta_releases_dict = json.loads('${{ steps.test-set-meta-releases.outputs.meta-releases-dict }}')
assert isinstance(meta_releases_dict, dict)
assert len(meta_releases_dict) > 0