Skip to content

Commit c3e0339

Browse files
authored
Update action to use reusable workflows (#569)
* Update workflows to use reusable-workflows * Update licensed.yml * Update workflows * Add links to reusable workflows * Update action to use reusable-workflows repo * Fix review points
1 parent 206e984 commit c3e0339

9 files changed

+37
-115
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Basic validation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
paths-ignore:
11+
- '**.md'
12+
jobs:
13+
call-basic-validation:
14+
name: Basic validation
15+
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main

.github/workflows/check-dist.yml

+3-38
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# `dist/index.js` is a special file in Actions.
2-
# When you reference an action with `uses:` in a workflow,
3-
# `index.js` is the code that will run.
4-
# For our project, we generate this file through a build process from other source files.
5-
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
61
name: Check dist/
72

83
on:
@@ -17,36 +12,6 @@ on:
1712
workflow_dispatch:
1813

1914
jobs:
20-
check-dist:
21-
runs-on: ubuntu-latest
22-
23-
steps:
24-
- uses: actions/checkout@v3
25-
26-
- name: Set Node.js 16.x
27-
uses: actions/setup-node@v3
28-
with:
29-
node-version: 16.x
30-
cache: npm
31-
32-
- name: Install dependencies
33-
run: npm ci
34-
35-
- name: Rebuild the dist/ directory
36-
run: npm run build
37-
38-
- name: Compare the expected and actual dist/ directories
39-
run: |
40-
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
41-
echo "Detected uncommitted changes after build. See status below:"
42-
git diff
43-
exit 1
44-
fi
45-
id: diff
46-
47-
# If index.js was different than expected, upload the expected version as an artifact
48-
- uses: actions/upload-artifact@v3
49-
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
50-
with:
51-
name: dist
52-
path: dist/
15+
call-check-dist:
16+
name: Check dist/
17+
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main

.github/workflows/codeql-analysis.yml

+5-39
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,13 @@
1-
name: "Code scanning - action"
1+
name: CodeQL analysis
22

33
on:
44
push:
55
branches: [ 'main' ]
66
pull_request:
77
schedule:
8-
- cron: '25 3 * * 5'
8+
- cron: '0 3 * * 0'
99

1010
jobs:
11-
CodeQL-Build:
12-
13-
strategy:
14-
fail-fast: false
15-
16-
# CodeQL runs on ubuntu-latest and windows-latest
17-
runs-on: ubuntu-latest
18-
19-
steps:
20-
- name: Checkout repository
21-
uses: actions/checkout@v3
22-
23-
# Initializes the CodeQL tools for scanning.
24-
- name: Initialize CodeQL
25-
uses: github/codeql-action/init@v2
26-
# Override language selection by uncommenting this and choosing your languages
27-
# with:
28-
# languages: go, javascript, csharp, python, cpp, java
29-
30-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
31-
# If this step fails, then you should remove it and run the build manually (see below)
32-
- name: Autobuild
33-
uses: github/codeql-action/autobuild@v2
34-
35-
# ℹ️ Command-line programs to run using the OS shell.
36-
# 📚 https://git.io/JvXDl
37-
38-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
39-
# and modify them (or add more) to build your code if your project
40-
# uses a compiled language
41-
42-
#- run: |
43-
# make bootstrap
44-
# make release
45-
46-
- name: Perform CodeQL Analysis
47-
uses: github/codeql-action/analyze@v2
11+
call-codeQL-analysis:
12+
name: CodeQL analysis
13+
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main

.github/workflows/workflow.yml .github/workflows/e2e-tests.yml

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: Main workflow
1+
name: e2e tests
2+
23
on:
34
push:
45
branches:
@@ -8,9 +9,10 @@ on:
89
pull_request:
910
paths-ignore:
1011
- '**.md'
12+
1113
jobs:
12-
run:
13-
name: Run
14+
test-setup-python:
15+
name: Test setup-python
1416
runs-on: ${{ matrix.operating-system }}
1517
strategy:
1618
matrix:
@@ -19,21 +21,6 @@ jobs:
1921
- name: Checkout
2022
uses: actions/checkout@v3
2123

22-
- name: Set Node.js 16.x
23-
uses: actions/setup-node@v3
24-
with:
25-
node-version: 16.x
26-
cache: npm
27-
28-
- name: npm ci
29-
run: npm ci
30-
31-
- name: Lint
32-
run: npm run format-check
33-
34-
- name: npm test
35-
run: npm test
36-
3724
- name: Run with setup-python 2.7
3825
uses: ./
3926
with:
@@ -98,4 +85,4 @@ jobs:
9885
- name: Verify 3.10
9986
run: python __tests__/verify-python.py 3.10
10087
- name: Run python-path sample 3.10
101-
run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version
88+
run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version

.github/workflows/licensed.yml

+3-18
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@ on:
99
- main
1010

1111
jobs:
12-
test:
13-
runs-on: ubuntu-latest
14-
name: Check licenses
15-
steps:
16-
- uses: actions/checkout@v3
17-
- name: Set Node.js 16.x
18-
uses: actions/setup-node@v3
19-
with:
20-
node-version: 16.x
21-
cache: npm
22-
- run: npm ci
23-
- name: Install licensed
24-
run: |
25-
cd $RUNNER_TEMP
26-
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
27-
sudo tar -xzf licensed.tar.gz
28-
sudo mv licensed /usr/local/bin/licensed
29-
- run: licensed status
12+
call-licensed:
13+
name: Licensed
14+
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main

.github/workflows/release-new-action-version.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Release new action version
2+
23
on:
34
release:
45
types: [released]
@@ -24,4 +25,4 @@ jobs:
2425
uses: actions/publish-action@v0.2.1
2526
with:
2627
source-tag: ${{ env.TAG_NAME }}
27-
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
28+
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

.github/workflows/test-pypy.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Validate PyPy e2e
2+
23
on:
34
push:
45
branches:

.github/workflows/test-python.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Validate Python e2e
2+
23
on:
34
push:
45
branches:

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts",
99
"format": "prettier --write \"{,!(node_modules)/**/}*.ts\"",
1010
"format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"",
11+
"lint": "echo \"Fake command that does nothing. It is used in reusable workflows\"",
1112
"release": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts && git add -f dist/",
1213
"test": "jest --coverage"
1314
},

0 commit comments

Comments
 (0)