Skip to content

Upgrade mockery to v3 #146

Upgrade mockery to v3

Upgrade mockery to v3 #146

Workflow file for this run

name: Test
on:
workflow_run:
workflows: ["Autogenerate"]
types:
- completed
push:
paths-ignore:
- "**.md"
- LICENSE
pull_request:
paths-ignore:
- "**.md"
- LICENSE
workflow_dispatch:
jobs:
autogen:
name: Generate mocks
runs-on: ubuntu-latest
# Permissions are needed to push the changes back to the repository
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.17
- name: Install Mockery
uses: jaxxstorm/[email protected]
with: # Grab a specific tag
repo: vektra/mockery
tag: v3.5.3
- name: Generate mocks
run: mockery --config .mockery.yml
- name: Cache generated mocks
uses: actions/cache@v4
with:
path: |
ocpp1.6_test/mocks/
ocpp2.0.1_test/mocks/
ocppj/mocks/
ws/mocks/
key: ${{ runner.os }}-mocks-${{ github.sha }}
unit:
runs-on: ubuntu-latest
name: Unit tests
needs: autogen
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Restore generated mocks
id: cache-mocks
uses: actions/cache/restore@v4
with:
path: |
ocpp1.6_test/mocks/
ocpp2.0.1_test/mocks/
ocppj/mocks/
ws/mocks/
key: ${{ runner.os }}-mocks-${{ github.sha }}
- name: Check cache hit
if: steps.cache-mocks.outputs.cache-hit != 'true'
run: exit 1
- name: Run tests
run: |
docker compose -f docker-compose.test.yaml up unit_test --abort-on-container-exit
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: unit_coverage_${{ github.sha }}
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_${{ github.sha }}
- name: Run integration tests
run: |
docker compose -f docker-compose.test.yaml up integration_test --abort-on-container-exit
- 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_${{ github.sha }}
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_${{ github.sha }}
- name: Publish
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}