generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (144 loc) · 5.05 KB
/
ci.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
---
name: CI
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
push:
branches: [master]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade -r requirements.txt
python -m pip install --upgrade -r requirements-dev.txt
- name: Test with pytest
id: test
env:
INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
python -m pytest \
-rxXs \
--tb=native \
--verbose \
--cov=action \
tests
- name: Upload coverage
# any except cancelled or skipped
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
uses: codecov/codecov-action@v3
action:
strategy:
fail-fast: false
matrix:
set:
- '0'
- '1'
- '2'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Action
id: action
uses: ./
with:
changelog_path: ./tests/data/set${{ matrix.set }}/CHANGELOG.md
fail_on_events_api_error: false # these scenarios do not exist in the GitHub events api
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Print action outputs
shell: bash
run: |
echo "changelog_exists: ${{ steps.action.outputs.changelog_exists }}"
echo "changelog_changes: ${{ steps.action.outputs.changelog_changes }}"
echo "changelog_date: ${{ steps.action.outputs.changelog_date }}"
echo "changelog_url: ${{ steps.action.outputs.changelog_url }}"
echo "changelog_version: ${{ steps.action.outputs.changelog_version }}"
echo "changelog_release_exists: ${{ steps.action.outputs.changelog_release_exists }}"
echo "publish_stable_release: ${{ steps.action.outputs.publish_stable_release }}"
echo "release_version: ${{ steps.action.outputs.release_version }}"
echo "release_tag: ${{ steps.action.outputs.release_tag }}"
- name: Verify changelog_exists
shell: bash
run: |
if [[ "${{ steps.action.outputs.changelog_exists }}" != "True" ]]; then
if [[ "${{ matrix.set }}" != "0" ]]; then
echo "changelog_exists is not true"
exit 1
fi
fi
- name: Verify changelog_changes
shell: bash
run: |
expected_changes=$(cat ./tests/data/set${{ matrix.set }}/changes.txt)
if [[ "${{ steps.action.outputs.changelog_changes }}" != "${expected_changes}" ]]; then
echo "changelog_changes does not match expected"
exit 1
fi
- name: Verify changelog_date
shell: bash
run: |
expected_date=$(cat ./tests/data/set${{ matrix.set }}/date.txt)
if [[ "${{ steps.action.outputs.changelog_date }}" != "${expected_date}" ]]; then
echo "changelog_date does not match expected"
exit 1
fi
- name: Verify changelog_url
shell: bash
run: |
expected_url=$(cat ./tests/data/set${{ matrix.set }}/url.txt)
if [[ "${{ steps.action.outputs.changelog_url }}" != "${expected_url}" ]]; then
echo "changelog_url does not match expected"
exit 1
fi
- name: Verify changelog_version
shell: bash
run: |
expected_version=$(cat ./tests/data/set${{ matrix.set }}/version.txt)
if [[ "${{ steps.action.outputs.changelog_version }}" != "${expected_version}" ]]; then
echo "changelog_version does not match expected"
exit 1
fi
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs:
- pytest
- action
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Action
id: setup-release
uses: ./
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
- name: Create Release
id: action
uses: LizardByte/create-release-action@master # keep this on master, to prevent endless depandabot PRs
with:
allowUpdates: false
artifacts: ''
body: ''
discussionCategory: announcements
generateReleaseNotes: true
name: ${{ steps.setup-release.outputs.release_tag }}
prerelease: ${{ steps.setup-release.outputs.publish_stable_release != 'true' }}
tag: ${{ steps.setup-release.outputs.release_tag }}
token: ${{ secrets.GH_BOT_TOKEN }}