Skip to content

📖 meh

📖 meh #259

Workflow file for this run

name: CI (repo level)
on:
push:
branches:
- "main"
- "release-*"
pull_request:
branches:
- "main"
- "release-*"
workflow_dispatch:
workflow_call:
concurrency:
group: ci-repo-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-test-lookup:
runs-on: ubuntu-latest
outputs:
builder-image: ${{ steps.grepBuilder.outputs.builder }}
should-test: ${{ steps.check-changes.outputs.should-test }}
steps:
- uses: actions/checkout@v4
- name: Lookup builder image from the project's Dockerfile
id: grepBuilder
run: |
builder=$(grep 'as builder' Dockerfile | sed -e 's/^FROM \(.*\) as builder$/\1/')
echo "Builder image: \`$builder\`" >> "$GITHUB_STEP_SUMMARY"
echo "builder=$builder" >> "$GITHUB_OUTPUT"
- name: Did non-build files change?
id: changed
uses: tj-actions/changed-files@v44
with:
files: |
docs/**
hack/**
*.md
- name: Check if only non-build changes have been made in a PR
id: check-changes
env:
IS_PR: ${{ !!github.event.pull_request }}
ANY_MODIFIED: ${{ steps.changed.outputs.only_changed }}
run: |
SHOULD_TEST=$(
if [[ $IS_PR == true ]] && [[ $ANY_MODIFIED == true ]]; then
echo "true"
else
echo "false"
fi
)
echo "is-pr=$IS_PR" >> "$GITHUB_OUTPUT"
echo "changed=${ANY_MODIFIED:-false}" >> "$GITHUB_OUTPUT"
echo "should-test=$SHOULD_TEST" >> "$GITHUB_OUTPUT"
- name: Summarize findings
env:
MODIFIED_FILES: ${{ steps.changed.outputs.all_modified_files }}
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## Findings
PR triggered? \`${{ steps.check-changes.outputs.is-pr }}\`
PR only includes non-build changes? \`${{ steps.check-changes.outputs.changed }}\`
Should the build be tested? \`${{ steps.check-changes.outputs.should-test }}\`
EOF
if [[ -n "$MODIFIED_FILES" ]]; then
echo "## Build related modified files" >> "$GITHUB_STEP_SUMMARY"
for file in ${MODIFIED_FILES}; do
echo " - \`$file\`" >> "$GITHUB_STEP_SUMMARY"
done
fi
unit-test:
runs-on: ubuntu-latest
needs: unit-test-lookup
if: ${{ needs.unit-test-lookup.outputs.should-test == 'true' }}
# Use the same container as the Dockerfile's "FROM * as builder"
container: ${{ needs.unit-test-lookup.outputs.builder-image }}
steps:
- uses: actions/checkout@v4
# TODO: Setup a cache for npm so it could install faster
# follow actions/setup-node@v4 techniques
- name: Verify package-lock.json
run: ./scripts/verify_lock.mjs
- name: Install
run: |
npm version
npm clean-install --ignore-scripts
- name: Lint sources
run: npm run lint
- name: Build
run: npm run build
- name: Test
run: npm run test -- --coverage --watchAll=false
- name: Upload to codecov (client)
# if: ${{ github.event.pull_request }}
uses: codecov/codecov-action@v4
with:
flags: client
directory: ./client/coverage
- name: Upload to codecov (server)
# if: ${{ github.event.pull_request }}
uses: codecov/codecov-action@v4
with:
flags: server
directory: ./server/coverage