-
Notifications
You must be signed in to change notification settings - Fork 180
120 lines (118 loc) · 4.07 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
name: Test
on:
- pull_request
- push
- workflow_call
- workflow_dispatch
jobs:
should-run:
name: Should run
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.0
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
test:
name: Run URL tests
needs:
- gsv
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:
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 }}
- run: echo "Tests succeeded!"