ops: Add gitea actions CI (#1)
Co-authored-by: Brock Allen <brock.d.allen@gmail.com> Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
103
.gitea/workflows/ci.yml
Normal file
103
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
name: ci
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: '0 1 * * 0'
|
||||
|
||||
# https://docs.docker.com/build/ci/github-actions/share-image-jobs/
|
||||
# just using caches instead of artifact upload.
|
||||
jobs:
|
||||
docker-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.20'
|
||||
-
|
||||
name: Create docker cache folder
|
||||
run: mkdir -p /tmp/docker
|
||||
-
|
||||
name: Hash dockerfile
|
||||
id: dockerfile-hash
|
||||
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
|
||||
with:
|
||||
patterns: builder.Dockerfile
|
||||
-
|
||||
name: Restore docker image
|
||||
id: cache-docker
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/docker
|
||||
key: ${{ runner.os }}-docker-${{ steps.dockerfile-hash.outputs.hash }}
|
||||
-
|
||||
name: Build docker builder-image
|
||||
if: steps.cache-docker.outputs.cache-hit != 'true'
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: builder.Dockerfile
|
||||
tags: cproject-builder:latest
|
||||
outputs: type=docker,dest=/tmp/docker/${{ runner.os }}-builder-image.tar
|
||||
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: docker-build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.20'
|
||||
-
|
||||
name: Hash dockerfile
|
||||
id: dockerfile-hash
|
||||
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
|
||||
with:
|
||||
patterns: builder.Dockerfile
|
||||
-
|
||||
name: Restore docker image
|
||||
id: cache-docker
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/docker
|
||||
key: ${{ runner.os }}-docker-${{ steps.dockerfile-hash.outputs.hash }}
|
||||
-
|
||||
name: Build library
|
||||
uses: https://github.com/addnab/docker-run-action@v3
|
||||
with:
|
||||
image: cproject-builder:latest
|
||||
options: --volumes-from ${{ env.JOB_CONTAINER_NAME }}
|
||||
run: |
|
||||
/bin/bash -c "cd ${{ github.workspace }}; rm -rf build; cmake -B build; cmake --build build"
|
||||
-
|
||||
name: Test library
|
||||
uses: https://github.com/addnab/docker-run-action@v3
|
||||
with:
|
||||
image: cproject-builder:latest
|
||||
options: --volumes-from ${{ env.JOB_CONTAINER_NAME }}
|
||||
run: |
|
||||
/bin/bash -c "cd ${{ github.workspace }}/tests/unittest; ceedling clobber; ceedling gcov:all; ceedling utils:gcov"
|
||||
-
|
||||
name: Archive coverage results
|
||||
shell: bash
|
||||
run: |
|
||||
staging="reports-${{github.run_number}}"
|
||||
mkdir -p "$staging"
|
||||
cp -r tests/unittest/build/artifacts/gcov "$staging"
|
||||
tar czf "$staging.tar.gz" "$staging"
|
||||
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
|
||||
-
|
||||
name: Archive artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: reports-${{github.run_number}}
|
||||
path: ${{ env.ASSET }}
|
||||
retention-days: 3
|
||||
|
||||
# TODO: delete cache on merge.
|
||||
Reference in New Issue
Block a user