Skip to content

Commit f42a127

Browse files
authored
[universal] Github Workflow Improvements (CloudPirates-io#358)
1 parent 9ba3946 commit f42a127

File tree

4 files changed

+161
-36
lines changed

4 files changed

+161
-36
lines changed

.github/workflows/auto-label.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ on:
55
pull_request:
66
types: [opened]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number }}
10+
cancel-in-progress: true
11+
812
jobs:
913
label:
1014
runs-on: ubuntu-latest
15+
timeout-minutes: 5
1116
permissions:
1217
issues: write
1318
pull-requests: write
1419
steps:
1520
- name: Apply labels
16-
uses: actions/github-script@v7
21+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
1722
with:
1823
script: |
1924
let content = "";

.github/workflows/check-signed-commits.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
name: Check signed commits in PR
22
on: pull_request_target
33

4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
6+
cancel-in-progress: true
7+
48
jobs:
59
check-signed-commits:
610
name: Check signed commits in PR
711
runs-on: ubuntu-latest
12+
timeout-minutes: 10
813
permissions:
914
contents: read
1015
pull-requests: write
1116
steps:
1217
- name: Checkout code
13-
uses: actions/checkout@v5.0.0
18+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1419
with:
1520
ref: ${{ github.event.pull_request.head.sha }}
1621
fetch-depth: 0
@@ -39,7 +44,7 @@ jobs:
3944
- name: Check signed commits in PR
4045
if: steps.check-bots.outputs.has_human_commits == 'true'
4146
continue-on-error: true
42-
uses: 1Password/check-signed-commits-action@v1
47+
uses: 1Password/check-signed-commits-action@ed2885f3ed2577a4f5d3c3fe895432a557d23d52 # v1.2.0
4348
with:
4449
comment: |
4550
## ⚠️ Unsigned Commits Detected

.github/workflows/pull-request.yaml

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,25 @@ on:
88
branches:
99
- main
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
lint-test:
1317
runs-on: ubuntu-latest
18+
timeout-minutes: 30
19+
permissions:
20+
contents: read
1421
outputs:
1522
changed: ${{ steps.list-changed.outputs.changed }}
1623
changedCharts: ${{ steps.list-changed.outputs.changedCharts }}
1724
steps:
1825
- name: Setup Helm
19-
uses: Azure/setup-helm@v4.3.1
26+
uses: Azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
2027

2128
- name: Checkout pull request branch
22-
uses: actions/checkout@v5.0.0
29+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2330
with:
2431
ref: ${{ github.head_ref }}
2532
repository: ${{github.event.pull_request.head.repo.full_name}}
@@ -28,12 +35,13 @@ jobs:
2835
# Python is required because `ct lint` runs Yamale (https://github.com/23andMe/Yamale) and
2936
# yamllint (https://github.com/adrienverge/yamllint) which require Python
3037
- name: Set up Python
31-
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
38+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
3239
with:
3340
python-version: 3.x
41+
cache: 'pip'
3442

3543
- name: Set up chart-testing-action
36-
uses: helm/chart-testing-action@v2.7.0
44+
uses: helm/chart-testing-action@0d28d3144d3a25ea2cc349d6e59901c4ff469b3b # v2.7.0
3745

3846
- name: Get changed charts
3947
id: list-changed
@@ -50,40 +58,70 @@ jobs:
5058
echo "No chart changes detected"
5159
fi
5260
61+
- name: Cache Helm plugins
62+
if: steps.list-changed.outputs.changed == 'true'
63+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
64+
with:
65+
path: ~/.local/share/helm/plugins
66+
key: ${{ runner.os }}-helm-plugins-${{ hashFiles('**/plugin.yaml') }}
67+
restore-keys: |
68+
${{ runner.os }}-helm-plugins-
69+
5370
- name: Installing plugin helm-unittest
5471
if: steps.list-changed.outputs.changed == 'true'
55-
run: helm plugin install https://github.com/helm-unittest/helm-unittest >/dev/null
72+
run: |
73+
if ! helm plugin list | grep -q unittest; then
74+
helm plugin install https://github.com/helm-unittest/helm-unittest
75+
else
76+
echo "helm-unittest plugin already installed"
77+
fi
5678
5779
- name: Run chart testing (lint & unittest)
5880
if: steps.list-changed.outputs.changed == 'true'
5981
run: ct lint --target-branch ${{ github.event.repository.default_branch }} --validate-maintainers=false --additional-commands "helm unittest {{ .Path }}"
6082

6183
integration-test:
6284
runs-on: ubuntu-latest
85+
timeout-minutes: 30
86+
permissions:
87+
contents: read
6388
needs: [lint-test]
6489
if: needs.lint-test.outputs.changed == 'true'
6590
steps:
6691
- name: Checkout pull request branch
67-
uses: actions/checkout@v5.0.0
92+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6893
with:
6994
ref: ${{ github.head_ref }}
7095
repository: ${{github.event.pull_request.head.repo.full_name}}
7196
fetch-depth: 0
7297

7398
- name: Setup Helm
74-
uses: Azure/setup-helm@v4.3.1
99+
uses: Azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
75100

76101
- name: Setup kubectl
77-
uses: azure/setup-kubectl@v4
102+
uses: azure/setup-kubectl@776406bce94f63e41d621b960d78ee25c8b76ede # v4.0.1
78103

79104
- name: Create kind cluster
80-
uses: helm/kind-action@v1.12.0
105+
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
81106
with:
82107
cluster_name: helm-chart-test
83108
wait: 300s
84109

110+
- name: Cache Helm plugins
111+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
112+
with:
113+
path: ~/.local/share/helm/plugins
114+
key: ${{ runner.os }}-helm-plugins-${{ hashFiles('**/plugin.yaml') }}
115+
restore-keys: |
116+
${{ runner.os }}-helm-plugins-
117+
85118
- name: Installing plugin helm-unittest
86-
run: helm plugin install https://github.com/helm-unittest/helm-unittest
119+
run: |
120+
if ! helm plugin list | grep -q unittest; then
121+
helm plugin install https://github.com/helm-unittest/helm-unittest
122+
else
123+
echo "helm-unittest plugin already installed"
124+
fi
87125
88126
- name: Run integration tests
89127
env:
@@ -104,6 +142,7 @@ jobs:
104142
105143
update-changelog:
106144
runs-on: ubuntu-latest
145+
timeout-minutes: 15
107146
needs: [lint-test]
108147
name: Automatically update CHANGELOG
109148
permissions:
@@ -112,7 +151,7 @@ jobs:
112151
if: always() && needs.lint-test.outputs.changed == 'true'
113152
steps:
114153
- name: Checkout PR branch
115-
uses: actions/checkout@v5.0.0
154+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
116155
with:
117156
repository: ${{ github.event.pull_request.head.repo.full_name }}
118157
ref: ${{ github.event.pull_request.head.ref }}
@@ -183,7 +222,7 @@ jobs:
183222
- name: Commit and push via GitHub API
184223
id: push-changes
185224
if: steps.check-changes.outputs.has_changes == 'true'
186-
uses: actions/github-script@v7
225+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
187226
with:
188227
github-token: ${{ secrets.GITHUB_TOKEN }}
189228
script: |

0 commit comments

Comments
 (0)