-
Notifications
You must be signed in to change notification settings - Fork 1
220 lines (214 loc) · 8.56 KB
/
test-actions.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
---
name: Test repository Actions
on:
push:
branches: [main]
merge_group:
pull_request:
branches: [main]
# Cancel running jobs for the same workflow and branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
# IMPORTANT: Any new jobs need to be added to the check-tests-passed job to ensure they correctly gate code changes
jobs:
test-create_unique_testpypi_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./actions/create_unique_testpypi_version
id: create-version
with:
package-name: example-package # this is an example package that is never updated
- name: Verify the new version number
run: |
if [ "${{ steps.create-version.outputs.new-version }}" != "0.0.1.post1" ]; then
echo "The new version number doesn't match the expected version number."
echo "Expected: 0.0.1.post1"
echo "Actual: ${{ steps.create-version.outputs.new-version }}"
exit 1
fi
test-find_unreleased_changelog_items:
runs-on: ubuntu-latest
env:
UNIT_TESTING_FIND_UNRELEASED_CHANGELOG_ITEMS_ACTION: true
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Overwrite CHANGELOG.md with dummy data
run: |
cat <<EOF > temp_changelog.md
# Changelog
---
## Unreleased
Things to be included in the next release go here.
### Added
- Something will be added
---
## v0.0.1
### Added
- Something was done here in the past
EOF
cp temp_changelog.md CHANGELOG.md
- uses: ./actions/find_unreleased_changelog_items
with:
release-level: patch
previous-changelog-filepath: python_semantic_release_templates/.testing_previous_changelog_for_template.md
previous-release-notes-filepath: python_semantic_release_templates/.testing_previous_release_notes_for_template.md
- name: Get Job Summary
uses: austenstone/job-summary@67b7e1f68ee55e44d073ab7354e7b580cd09567c # v2.0
id: job-summary
with:
name: temp_job_summary
create-pdf: false
create-pdf-artifact: false
create-md: true
create-md-artifact: false
- name: Compare CHANGELOG.md with the created copy
run: |
FILE1="./temp_changelog.md"
FILE2="./python_semantic_release_templates/.testing_previous_changelog_for_template.md"
if diff "$FILE1" "$FILE2" > /dev/null; then
echo "The changelog files are identical."
else
echo "The changelog files are different. Here is the diff:"
diff "$FILE1" "$FILE2"
exit 1
fi
- name: Verify created Release Notes
run: |
FILE_PATH="./python_semantic_release_templates/.testing_previous_release_notes_for_template.md"
# Define the multiline string using a heredoc
MULTILINE_STRING=$(cat <<'EOF'
## Unreleased
Things to be included in the next release go here.
### Added
- Something will be added
EOF
)
# Compare the file contents to the multiline string
if diff <(echo "$MULTILINE_STRING") "$FILE_PATH" > /dev/null; then
echo "The Release Notes contents are correct."
else
echo "The Release Notes contents are not correct. Here is the diff:"
diff <(echo "$MULTILINE_STRING") "$FILE_PATH"
exit 1
fi
- name: Verify the Job Summary
run: |
FILE_PATH="./temp_job_summary.md"
# Define the start and end parts of the multiline string using heredocs
START_STRING=$(cat <<'EOF'
## Workflow Inputs
- release-level: patch
## PRs Merged Since Last Release
EOF
)
END_STRING=$(cat <<'EOF'
## Incoming Changes
Things to be included in the next release go here.
### Added
- Something will be added
EOF
)
# Read file contents
FILE_CONTENTS=$(cat "$FILE_PATH")
# Extract the start and end parts of the file contents
FILE_START=$(echo "$FILE_CONTENTS" | head -n "$(echo "$START_STRING" | wc -l)")
FILE_END=$(echo "$FILE_CONTENTS" | tail -n "$(echo "$END_STRING" | wc -l)")
# Compare the start and end parts
if [ "$FILE_START" == "$START_STRING" ] && [ "$FILE_END" == "$END_STRING" ]; then
echo "The Job Summary contents are correct."
else
echo "The Job Summary contents are not correct."
echo ""
echo "Expected start:"
echo "$START_STRING"
echo ""
echo "Actual start:"
echo "$FILE_START"
echo ""
echo ""
echo "Expected end:"
echo "$END_STRING"
echo ""
echo "Actual end:"
echo "$FILE_END"
exit 1
fi
test-update_development_dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./actions/update_development_dependencies
with:
update-pre-commit: true
run-pre-commit: true
dependency-dict: '{"dev": ["pyright"]}'
pre-commit-repo-update-skip-list: https://github.com/pre-commit/pre-commit-hooks,https://github.com/executablebooks/mdformat
pre-commit-hook-skip-list: remove-tabs,forbid-tabs,check-readthedocs,check-dependabot,check-github-actions,check-github-workflows,commitizen,blacken-docs,yamlfix,hadolint,mdformat,markdown-link-check,check-poetry,toml-sort-fix,pyright,poetry-audit,ruff,ruff-format,docformatter,renovate-config-validator,actionlint
export-dependency-groups: |
actions-update_development_dependencies:actions/update_development_dependencies,
tests
test-fetch_pr_number:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Fetch known PR number
uses: ./actions/fetch_pr_number
id: fetch-pr-number-found
with:
sha: 7a6fb39bda8ace8217530c3bc79407333462fc30
github-repository: ${{ github.repository }}
- name: Verify the PR number
run: |
if [ "${{ steps.fetch-pr-number-found.outputs.number }}" != "30" ]; then
echo "The fetched PR number doesn't match the expected PR number."
echo "Expected: 30"
echo "Actual: ${{ steps.fetch-pr-number-found.outputs.number }}"
exit 1
fi
- name: Fetch known PR number from a fork
uses: ./actions/fetch_pr_number
id: fetch-pr-number-found-fork
with:
sha: 9163270797352721c78d82054f6ead259f2f7366
github-repository: ${{ github.repository }}
- name: Verify the PR number from a fork
run: |
if [ "${{ steps.fetch-pr-number-found-fork.outputs.number }}" != "31" ]; then
echo "The fetched PR number doesn't match the expected PR number."
echo "Expected: 31"
echo "Actual: ${{ steps.fetch-pr-number-found.outputs.number }}"
exit 1
fi
- name: Fetch unknown PR number
uses: ./actions/fetch_pr_number
id: fetch-pr-number-not-found
with:
sha: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
github-repository: ${{ github.repository }}
max-attempts: 2
retry-delay: 2
continue-on-error: true # This step should fail
- name: Verify no PR number was found and the previous step failed
run: |
if [ "${{ steps.fetch-pr-number-not-found.outcome }}" != "failure" ]; then
echo "Step did not fail as expected."
exit 1
else
echo "Step failed as expected."
fi
# Check that all jobs passed
check-action-tests-passed:
if: ${{ !cancelled() }}
needs:
- test-create_unique_testpypi_version
- test-find_unreleased_changelog_items
- test-update_development_dependencies
- test-fetch_pr_number
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}