-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (67 loc) · 2.62 KB
/
quality-checks.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
name: quality-checks
run-name: 🔬 @${{ github.triggering_actor }} is checking quality on ${{ github.ref_name }}
on: [push]
jobs:
unit-tests:
name: 🧪 unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "version=$(grep -Ee 'go [0-9\.]+' go.mod | awk '{ print $2; }')" >> $GITHUB_OUTPUT
id: go_mod
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.go_mod.outputs.version }}
cache-dependency-path: "**/*.sum"
- run: go test ./...
enumerate-integration-tests:
name: 🔎 enumerate buildpack tests
runs-on: ubuntu-latest
needs: [ unit-tests ]
outputs:
tests: ${{ steps.buildpack-tests.outputs.result }}
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
id: buildpack-tests
with:
result-encoding: json
script: |
const {readdir, stat, readFile} = require("node:fs/promises");
const {join, relative} = require("node:path");
return await readdir(process.cwd())
.then(dirs => Promise.all(dirs.map(async d => {
try {
await stat(join(process.cwd(), d, 'buildpack.toml'));
return relative(process.cwd(), join(process.cwd(), d));
} catch (e) {
return null;
}
})))
.then(dirs => dirs.filter(d => Boolean(d)))
.then(dirs => Promise.all(dirs.map(async d => {
const makefile = (await readFile(join(process.cwd(), d, 'Makefile'))).toString();
return makefile.match(/^test-[^:]+/mg)?.map(t => `${d}:${t}`);
})))
.then(dirs => dirs.flat())
.then(dirs => dirs.filter(d => Boolean(d)));
integration-tests:
name: ⚙️ integration test ${{ matrix.buildpack-test }}
needs: [ enumerate-integration-tests ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
buildpack-test: ${{ fromJSON(needs.enumerate-integration-tests.outputs.tests) }}
steps:
- uses: actions/checkout@v4
- id: setup-tools
uses: buildpacks/github-actions/[email protected]
- id: setup-pack
uses: buildpacks/github-actions/[email protected]
- run: |
BUILDPACK="$(cut -d':' -f1 <<< "${{ matrix.buildpack-test }}")"
TEST_NAME="$(cut -d':' -f2 <<< "${{ matrix.buildpack-test }}")"
echo "Testing buildpack $BUILDPACK with $TEST_NAME"
cd $BUILDPACK || exit 1
make $TEST_NAME