Skip to content

Repository maintenance: CI and testing improvements #5

Repository maintenance: CI and testing improvements

Repository maintenance: CI and testing improvements #5

Workflow file for this run

name: Test
on: [ push, pull_request, workflow_dispatch ]
jobs:
unit:
runs-on: ubuntu-latest
name: Unit tests
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Install Go
uses: actions/[email protected]
with:
go-version: ^1.18
cache: true
- name: Run tests
run: |
docker compose -f docker-compose.test.yaml up unit_test --abort-on-container-failure
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: unit_coverage
path: ./coverage.out
integration:
name: Integration tests
runs-on: ubuntu-latest
needs: unit
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Download coverage from unit tests
uses: actions/download-artifact@v4
with:
name: unit_coverage
- name: Run integration tests
run: |
docker compose -f docker-compose.test.yaml up integration_test --abort-on-container-failure
- name: Wait for integration_test to finish
run: |
while [ "$(docker inspect -f '{{.State.Running}}' $(docker compose -f docker-compose.test.yaml ps -q integration_test))" == "true" ]; do
echo "Waiting for integration_test to finish..."
sleep 5
done
- name: Merge coverage
run: |
sed '1d;$d' integration_coverage.out >> coverage.out
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: coverage
path: ./coverage.out
publish_coverage:
runs-on: ubuntu-latest
# Unit and integration tests must be run before publishing coverage
needs: [ unit, integration ]
name: Publish coverage
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Download coverage from tests
uses: actions/download-artifact@v4
with:
name: coverage
- name: Publish
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}