Skip to content

Commit

Permalink
ci: use github action for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rueian committed Apr 24, 2024
1 parent 0e082d9 commit 1702753
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Go Modules Test

on: [push, pull_request]

jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: |
echo "::set-output name=matrix::$(find . -maxdepth 2 -type f -name 'go.mod' | xargs -n 1 dirname | sort -u | jq -R -s -c 'split("\n")[:-1]')"
build:
needs: prepare-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21.0'

- name: Test Module
run: |
module_path=${{ matrix.module }}
if [ "$module_path" == "." ]; then
list=$(go list ./...)
echo "Test Packages: $list"
for n in {1..5}; do
./dockertest.sh $list && break
done
else
cd $module_path
list=$(go list ./...)
echo "Test Packages: $list"
for n in {1..5}; do
../dockertest.sh $list && break
done
fi
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

0 comments on commit 1702753

Please sign in to comment.