Merge pull request #2243 from saltstack/renovate/github-actions-minor… #724
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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 | |
- 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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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 | |
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 }} |