-
Notifications
You must be signed in to change notification settings - Fork 180
182 lines (179 loc) · 6.79 KB
/
main.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
name: Test
on:
- pull_request
- push
- workflow_call
- workflow_dispatch
env:
REPO_JSON_DIR: repo_data
REPO_JSON_FILE: repo.json
jobs:
should-run:
name: Should run
permissions:
pull-requests: read
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
should-run: ${{ steps.action.outputs.should-run }}
steps:
- id: action
uses: techneg-it/should-workflow-run@dcbb88600d59ec2842778ef1e2d41f680f876329 # v1.0.0
pre-commit:
name: Run `pre-commit`
needs: should-run
if: fromJSON(needs.should-run.outputs.should-run)
runs-on: ubuntu-latest
env:
# renovate: datasource=custom.python-versions depName=actions/python-versions versioning=pep440
PYTHON_VERSION: 3.13.1
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
gsv:
name: Get Salt versions
needs: should-run
if: fromJSON(needs.should-run.outputs.should-run)
runs-on: ubuntu-latest
outputs:
salt-versions-els: ${{ steps.get-salt-versions.outputs.salt-versions-els }}
salt-versions: ${{ steps.get-salt-versions.outputs.salt-versions }}
salt-latest: ${{ steps.get-salt-versions.outputs.salt-latest }}
steps:
- id: get-salt-versions
uses: dafyddj/get-salt-versions@847b788138982a01def107014dd395b46b3ef2c5 # v3.3.1
refresh_db:
name: Test `pkg.refresh_db`
needs: gsv
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
salt-version:
- ${{ fromJSON(needs.gsv.outputs.salt-versions-els) }}
- ${{ fromJSON(needs.gsv.outputs.salt-versions) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: win/repo-ng
- name: Setup Salt
uses: dafyddj/setup-salt-win@a81ff6460b4847498f56176fce5b5f76c5fc5de0 # v3.1.0
with:
salt-version: ${{ matrix.salt-version }}
custom-config: |
osenv:
driver: env
file_roots:
base:
- sdb://osenv/GITHUB_WORKSPACE
- name: Run `salt-call pkg.refresh_db`
run: |
$pkgs = (salt-call --out=json pkg.refresh_db | ConvertFrom-Json).local
if ($LASTEXITCODE) {
Write-Host ("::error title=salt-call::salt-call returned exit code: $LASTEXITCODE")
exit 1
}
$pkgs
- name: Run `salt-call pkg.get_repo_data` (Only for latest Salt version)
if: needs.gsv.outputs.salt-latest == matrix.salt-version
run: |
salt-call --out=json pkg.get_repo_data > $env:REPO_JSON_FILE
if ($LASTEXITCODE) {
Write-Host ("::error title=salt-call::salt-call returned exit code: $LASTEXITCODE")
exit 1
}
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: needs.gsv.outputs.salt-latest == matrix.salt-version
with:
if-no-files-found: error
name: ${{ env.REPO_JSON_DIR }}
path: ${{ env.REPO_JSON_FILE }}
retention-days: 10
test:
name: Run URL tests
needs:
- gsv
permissions:
contents: read
pull-requests: read
runs-on: windows-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: changed-files
name: Get changed files
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
list-files: json
filters: |
sls:
- added|modified:
- '**/*.sls'
- name: Setup Salt
if: steps.changed-files.outputs.sls == 'true'
uses: dafyddj/setup-salt-win@a81ff6460b4847498f56176fce5b5f76c5fc5de0 # v3.1.0
with:
salt-version: ${{ needs.gsv.outputs.salt-latest }}
- name: Setup `pip` dependencies
if: steps.changed-files.outputs.sls == 'true'
run: |
salt-pip install -r .cicd/requirements.txt
if ($LASTEXITCODE) {
Write-Host ("::error title=salt-pip::salt-pip returned exit code: $LASTEXITCODE")
exit 1
}
- name: Run URL test
if: steps.changed-files.outputs.sls == 'true'
run: |
& "C:\Program Files\Salt Project\Salt\Scripts\python.exe" .\.cicd\tests.py ${{ join(fromJSON(steps.changed-files.outputs.sls_files), ' ') }}
results:
name: Collect results
permissions:
contents: write
issues: write
pull-requests: write
checks: read
runs-on: ubuntu-latest
steps:
- uses: poseidon/wait-for-status-checks@899c768d191b56eef585c18f8558da19e1f3e707 # v0.6.0
with:
ignore: Collect results
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.cicd/
.releaserc.cjs
- id: sem-rel
uses: codfish/semantic-release-action@b621d34fabe0940f031e89b6ebfea28322892a10 # v3.5.0
with:
additional-packages: conventional-changelog-conventionalcommits@7.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: runner.debug || fromJSON(steps.sem-rel.outputs.new-release-published)
- name: Transform dumped repo data to Renovate-style JSON
if: runner.debug || fromJSON(steps.sem-rel.outputs.new-release-published)
run: |
if [ -f "$REPO_JSON_DIR/$REPO_JSON_FILE" ]; then
.cicd/transform-json < "$REPO_JSON_DIR/$REPO_JSON_FILE"
echo "::group::Display resulting directory structure"
ls --almost-all --recursive --ignore node_modules --ignore .git
echo "::endgroup::"
fi
- uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
if: fromJSON(steps.sem-rel.outputs.new-release-published)
with:
commit_message: |
deploy: ${{ steps.sem-rel.outputs.git-tag }}
destination_dir: ${{ steps.sem-rel.outputs.git-tag }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
if: fromJSON(steps.sem-rel.outputs.new-release-published)
with:
commit_message: |
deploy: ${{ steps.sem-rel.outputs.git-tag }} on ${{ steps.sem-rel.outputs.channel }}
destination_dir: ${{ steps.sem-rel.outputs.channel }}
github_token: ${{ secrets.GITHUB_TOKEN }}