90 lines
2.5 KiB
YAML
90 lines
2.5 KiB
YAML
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/gh-action-get-changed-files@2.1.4
|
|
id: diff
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Generate testing matrix
|
|
uses: actions/github-script@v3
|
|
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) }}
|
|
|
|
steps:
|
|
- name: Get short node version
|
|
uses: actions/github-script@v3
|
|
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: .
|
|
file: ./${{ steps.short-version.outputs.result }}/${{ matrix.variant }}/Dockerfile
|
|
tags: node:${{ matrix.version }}-${{ matrix.variant }}
|
|
|
|
- name: Test for node version
|
|
run: |
|
|
image_node_version=$(docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} node --print "process.versions.node")
|
|
echo "Expected: \"${{ matrix.version }}\", Got: \"${image_node_version}\""
|
|
[ "${image_node_version}" == "${{ matrix.version }}" ]
|
|
|
|
- name: Test for npm
|
|
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} npm --version
|
|
|
|
- name: Test for yarn
|
|
run: docker run --rm node:${{ matrix.version }}-${{ matrix.variant }} yarn --version
|