diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..deebaeb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + push: + branches: + - '**' + pull_request: + types: [opened, reopened] + branches: + - '**' + +jobs: + unit_tests: + name: "Unit tests" + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ^1.22 + + - name: Test + run: go test -v -cover -coverprofile=coverage.txt -covermode=count ./... + + - name: Archive code coverage results + uses: actions/upload-artifact@v4 + with: + name: code-coverage + path: coverage.txt + + code_coverage: + name: "Code coverage report" + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + needs: unit_tests + steps: + - name: Download code coverage results from source branch + run: 'echo "TODO: Download code coverage results from source branch"' + + - name: Download code coverage results + uses: actions/download-artifact@v4 + with: + name: code-coverage + path: source-coverage.txt + + - name: Compare code coverage results + run: 'echo "## Coverage report" > coverage-comment.md' + + - name: Comment on pull request + run: gh pr comment ${{ github.event.number }} --body-file coverage-comment.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index d3a15b3..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Unit Tests - -on: [push] - -jobs: - - build: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ^1.22 - - - name: Test - run: go test -v -cover -coverprofile=coverage.txt -covermode=count ./... - - - name: Archive code coverage results - uses: actions/upload-artifact@v4 - with: - name: code-coverage - path: coverage.txt