ci: add ci for pull requests #15
Workflow file for this run
This file contains hidden or 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
| name: run CI | |
| on: | |
| pull_request: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }}:${{ github.base_ref }} | |
| jobs: | |
| lint-and-test: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull image | |
| run: | | |
| docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Start docker container | |
| run: | | |
| docker run -d \ | |
| --name ci-container \ | |
| -v ${{ github.workspace }}:/work \ | |
| -w /work \ | |
| ghcr.io/${{ env.IMAGE_NAME }} \ | |
| tail -f /dev/null # keep the container up and runnning | |
| - name: Prepare docker container | |
| run: | | |
| docker exec -u root ci-container sh -c " | |
| git config --global --add safe.directory /work | |
| useradd ubuntu || true | |
| chown -R ubuntu:ubuntu /work | |
| sudo -H -u ubuntu make install-dependencies | |
| sudo -H -u ubuntu make build | |
| " | |
| - name: Lint | |
| run: | | |
| docker exec -u root ci-container sh -c "sudo -H -u ubuntu make lint" | |
| - name: Test | |
| run: | | |
| docker exec -u root ci-container sh -c "sudo -H -u ubuntu make test" | |
| - name: Remove container | |
| if: always() | |
| run: docker rm -f ci-container | |
| - name: Archive logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-reports | |
| path: | | |
| /work/junit*.xml |