Merge pull request #1442 from bnb-chain/develop #6287
This file contains 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: Unit Test | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- fix-release* | |
pull_request: | |
branches: | |
env: | |
CGO_CFLAGS: "-O -D__BLST_PORTABLE__" | |
CGO_CFLAGS_ALLOW: "-O -D__BLST_PORTABLE__" | |
jobs: | |
unit-test: | |
strategy: | |
matrix: | |
go-version: [1.20.x] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
# In order: | |
# * Module download cache | |
# * Build cache (Linux) | |
# * Build cache (Mac) | |
# * Build cache (Windows) | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
~/Library/Caches/go-build | |
%LocalAppData%\go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- uses: bufbuild/buf-setup-action@v1.14.0 | |
with: | |
version: 1.14.0 | |
buf_user: "${{ secrets.BUF_REGISTRY_USER }}" | |
buf_api_token: "${{ secrets.BUF_REGISTRY_SECRET }}" | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- run: | | |
make install-tools | |
make buf-gen | |
- name: Unit Test | |
run: | | |
make test | |
- name: make coverage report | |
id: coverage-report | |
if: github.event_name == 'pull_request' | |
continue-on-error: true | |
run: | | |
echo '## Test Coverage Report' >> coverage-report.txt | |
echo 'commit-id: ${{ github.event.pull_request.head.sha }}' >> coverage-report.txt | |
echo 'generated by https://github.com/vladopajic/go-test-coverage' >> coverage-report.txt | |
echo >> coverage-report.txt | |
echo '<details><summary>Additional details and impacted files</summary>' >> coverage-report.txt | |
echo >> coverage-report.txt | |
echo '```' >> coverage-report.txt | |
make check-coverage >> coverage-report.txt | |
echo '```' >> coverage-report.txt | |
echo >> coverage-report.txt | |
echo '</details>' >> coverage-report.txt | |
cat coverage-report.txt >> $GITHUB_STEP_SUMMARY |