-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (99 loc) · 4.13 KB
/
validate.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: Validation Pipeline
on:
# Enable workflow as callable from other workflow
workflow_call:
# inputs: none required ATT
# outputs: none required ATT
# secrets: none required ATT
# set default Token permissions = none
permissions: {}
jobs:
eval-changes:
name: Evaluate changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 50 # Must at least retrieve a set of commits to compare changes
# primarily because of any 'Rebase and Merge' PR action in GitHub
- name: Evaluate | Check specific file types for changes
id: changed-files
uses: tj-actions/[email protected]
if: github.event_name == 'push' || github.event_name == 'pull_request'
with:
base_sha: ${{ github.event.push.before || github.event.pull_request.base.sha }}
# action.yml is not considered as src because we can't test it
files_yaml: |
ci:
- .github/workflows/validate.yml
- .github/workflows/ci.yml
docs:
- AUTHORS.rst
- CONTRIBUTING.rst
- LICENSE
- README.md
src:
- src/**
tests:
- tests/**
- name: Evaluate | Detect if any of the combinations of file sets have changed
id: all-changes
if: ${{ steps.changed-files.outcome == 'success' }}
run: |
printf '%s\n' "any_changed=false" >> $GITHUB_OUTPUT
if [ "${{ steps.changed-files.outputs.ci_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.docs_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.src_any_changed }}" == "true" ] || \
[ "${{ steps.changed-files.outputs.tests_any_changed }}" == "true" ]; then
printf '%s\n' "any_changed=true" >> $GITHUB_OUTPUT
fi
- name: Evaluate | Handle manual trigger (lie that all files changed)
id: manual-trigger
if: github.event_name == 'workflow_dispatch'
run: |
printf '%s\n' "ci_any_changed=true" >> $GITHUB_OUTPUT
printf '%s\n' "docs_any_changed=true" >> $GITHUB_OUTPUT
printf '%s\n' "src_any_changed=true" >> $GITHUB_OUTPUT
printf '%s\n' "tests_any_changed=true" >> $GITHUB_OUTPUT
printf '%s\n' "any_changed=true" >> $GITHUB_OUTPUT
outputs:
any-file-changes: ${{ steps.all-changes.outputs.any_changed || steps.manual-trigger.outputs.any_changed }}
ci-changes: ${{ steps.changed-files.outputs.ci_any_changed || steps.manual-trigger.outputs.ci_any_changed }}
doc-changes: ${{ steps.changed-files.outputs.docs_any_changed || steps.manual-trigger.outputs.docs_any_changed }}
src-changes: ${{ steps.changed-files.outputs.src_any_changed || steps.manual-trigger.outputs.src_any_changed }}
test-changes: ${{ steps.changed-files.outputs.tests_any_changed || steps.manual-trigger.outputs.tests_any_changed }}
commitlint:
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Validate | Commitlint
uses: wagoid/commitlint-github-action@v6
validate-action:
name: Validate Action Build & Execution
runs-on: ubuntu-latest
if: needs.eval-changes.outputs.src-changes == 'true' || needs.eval-changes.outputs.test-changes == 'true' || needs.eval-changes.outputs.ci-changes == 'true'
needs:
- eval-changes
env:
TEST_CONTAINER_TAG: psr-publish-action:latest
steps:
- name: Setup | Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.sha }}
- name: Build | Action Container
id: container-builder
uses: docker/build-push-action@v6
with:
context: ./src
load: true # add to `docker images`
push: false
platforms: linux/amd64
tags: ${{ env.TEST_CONTAINER_TAG }}
- name: Test | Action Container
run: bash tests/run.sh