Skip to content

chore: improve test readability (#157) #664

chore: improve test readability (#157)

chore: improve test readability (#157) #664

Workflow file for this run

name: note-c CI Pipeline
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
check_dockerfile_changed:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout code
uses: actions/checkout@v3
# TODO: This is a 3rd party GitHub action from some dude. Ideally, we'd
# use something more "official".
- name: Check if Dockerfile changed
uses: dorny/paths-filter@v2
id: filter
with:
base: 'master'
filters: |
changed:
- 'Dockerfile'
build_ci_docker_image:
runs-on: ubuntu-latest
needs: [check_dockerfile_changed]
if: ${{ needs.check_dockerfile_changed.outputs.changed == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Rebuild image
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ghcr.io/blues/note_c_ci:latest
outputs: type=docker,dest=/tmp/note_c_ci_image.tar
- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: note_c_ci_image
path: /tmp/note_c_ci_image.tar
build_docs:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Build docs
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/build_docs.sh ghcr.io/blues/note_c_ci:latest
check_libc_dependencies:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Check note-c's libc dependencies
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/check_libc_dependencies.sh ghcr.io/blues/note_c_ci:latest
run_unit_tests:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Load CI Docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run tests
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_unit_tests.sh ghcr.io/blues/note_c_ci:latest --coverage --mem-check
- name: Adjust lcov source file paths for Coveralls
run: sudo sed -i 's/\/note-c\///g' ./build/test/coverage/lcov.info
- name: Publish test coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build/test/coverage/lcov.info
run_low_mem_unit_tests:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Load CI Docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run tests with NOTE_LOWMEM defined
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_unit_tests.sh ghcr.io/blues/note_c_ci:latest --mem-check --low-mem --single-precision
run_astyle:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Load CI Docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run astyle
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_astyle.sh ghcr.io/blues/note_c_ci:latest
publish_ci_image:
runs-on: ubuntu-latest
# Make sure unit tests unit tests passed before publishing.
needs: [build_ci_docker_image, run_unit_tests]
# Only publish the image if this is a push event and the Docker image was rebuilt
if: ${{ github.event_name == 'push' && needs.build_ci_docker_image.result == 'success' }}
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Push image to registry
uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/blues/note_c_ci:latest