Run matrix test per package #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Node.js CI | |
on: | |
push: | |
branches: ['master'] | |
pull_request: | |
branches: ['master'] | |
jobs: | |
test: | |
if: ${{ ! endsWith(github.event.head_commit.message, '[skip ci]') }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: | |
[ | |
'archive', | |
'base-node', | |
'common-archive-client', | |
'common-data', | |
'common-postgres', | |
'configurator', | |
'gatherer-http', | |
'gatherer-stdin', | |
'infra-postgres', | |
'infra-redis', | |
'listener', | |
'publisher', | |
] | |
target: ['lint', 'test'] | |
node-version: [20.x, 22.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- run: npm install | |
- run: npx nx run-many --target=${{ matrix.target }} --projects=${{ matrix.package }} --output-style=stream | |
build: | |
if: ${{ ! endsWith(github.event.head_commit.message, '[skip ci]') }} | |
runs-on: ubuntu-latest | |
needs: test | |
strategy: | |
matrix: | |
package: ['base-node', 'archive'] | |
node-version: [20.x] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup node 20 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Run npm install | |
run: npm install | |
- name: Run node build | |
run: npx nx run ${{ matrix.package }}:node:build --output-style=stream | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./packages/${{ matrix.package }} | |
push: true | |
tags: ghcr.io/${{ github.repository }}/${{ matrix.package}}:latest, ghcr.io/${{ github.repository }}/${{ matrix.package}}:${{ github.sha }} | |
- uses: mikefarah/yq@master | |
with: | |
cmd: yq --version | |
- name: Update image version tag | |
run: | | |
git config --global user.email "juhani.pelli@gmail.com" | |
git config --global user.name "Juhani Pelli" | |
yq e '.images[0].newTag = "${{ github.sha }}"' -i packages/${{ matrix.package }}/.khz-k3s/kustomization.yaml | |
git add packages/${{ matrix.package }}/.khz-k3s/kustomization.yaml | |
git commit -m "Deploy ${{ github.sha }} [skip ci]" | |
git push origin ${{ github.event.repository.default_branch }} |