-
Notifications
You must be signed in to change notification settings - Fork 2k
82 lines (70 loc) · 2.11 KB
/
build-test.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
name: build-test
on:
push:
paths:
- "**/Dockerfile"
- "**/docker-entrypoint.sh"
- genMatrix.js
- ".github/workflows/build-test.yml"
pull_request:
paths:
- "**/Dockerfile"
- "**/docker-entrypoint.sh"
- genMatrix.js
- ".github/workflows/build-test.yml"
jobs:
gen-matrix:
name: generate-matrix
runs-on: ubuntu-latest
steps:
- name: Calculate file differences
uses: lots0logs/[email protected]
id: diff
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2
- name: Generate testing matrix
uses: actions/[email protected]
id: generator
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/genMatrix.js`)
return script(
${{ steps.diff.outputs.added }},
${{ steps.diff.outputs.modified }},
${{ steps.diff.outputs.renamed }},
);
outputs:
matrix: ${{ steps.generator.outputs.result }}
build:
if: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
needs: gen-matrix
name: build
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
env:
NODE_VERSION: ${{ matrix.version }}
IMAGE_TAG: node:${{ matrix.version }}-${{ matrix.variant }}
steps:
- name: Get short node version
uses: actions/[email protected]
id: short-version
with:
result-encoding: string
script: return "${{ matrix.version }}".split('.')[0]
- name: Checkout
uses: actions/checkout@v2
- name: Build image
uses: docker/build-push-action@v2
with:
push: false
load: true
context: ./${{ steps.short-version.outputs.result }}/${{ matrix.variant }}
tags: ${{ env.IMAGE_TAG }}
- name: Run tests with BATS
run: npx [email protected] --verbose-run test/docker-image.bats