From 92fe411b64198691d5fec9bf893d635d692eb6ab Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Wed, 27 Dec 2023 12:42:00 +1100 Subject: [PATCH] CI: rework GitHub action --- .github/workflows/ci.yaml | 134 +++++++++++++++++++++++++++++++------- 1 file changed, 111 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index af8e5cc..28792a1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,30 +15,118 @@ env: AWS_SECRET_ACCESS_KEY: 'DUMMYKEY' AWS_DYNAMODB_ENDPOINT: 'http://localhost:8000' AWS_DYNAMODB_URL: 'Endpoint=http://localhost:8000' + TAG_PREFIX: 'v' jobs: - testLocal: - name: Test against AWS DynamoDB local + GoFmt: runs-on: ubuntu-latest + name: Check format with go fmt steps: - - name: Set up Go env - uses: actions/setup-go@v4 - with: - go-version: ^1.13 - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - name: Start AWS DynamoDB local server - run: docker run -d --name dynamodb -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -inMemory -sharedDb - - name: Test - run: | - export AWS_REGION="us-east-1" - export AWS_ACCESS_KEY_ID="DUMMYID" - export AWS_SECRET_ACCESS_KEY="DUMMYKEY" - export AWS_DYNAMODB_ENDPOINT="http://localhost:8000" - export AWS_DYNAMODB_URL="Endpoint=http://localhost:8000" - go test -v -timeout 9999s -count 1 -p 1 -cover -coverprofile coverage_local.txt . - - name: Codecov - uses: codecov/codecov-action@v3 - with: - flags: local - name: local + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go env + uses: actions/setup-go@v5 + with: + go-version: 'stable' + - name: Run go fmt + run: | + go version + go fmt ./... + + GoLint: + name: GoLint + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go env + uses: actions/setup-go@v5 + with: + go-version: 'stable' + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + only-new-issues: true + + ReleaseDryRun: + if: github.event_name == 'push' + runs-on: ubuntu-latest + needs: [ GoFmt, GoLint ] + outputs: + RESULT: ${{ steps.release_dry_run.outputs.result }} + VERSION: ${{ steps.release_dry_run.outputs.releaseVersion }} + RELEASE_NOTES: ${{ steps.release_dry_run.outputs.releaseNotes }} + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + - name: Release (dry-run) + id: release_dry_run + uses: btnguyen2k/action-semrelease@v3 + with: + dry-run: true + auto-mode: true + github-token: ${{ secrets.GITHUB_TOKEN }} + tag-major-release: false + tag-minor-release: false + branches: ${{ github.ref_name }} + tag-prefix: ${{ env.TAG_PREFIX }} + tag-only: true + + TestParsing: + runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.18', 'oldstable', 'stable' ] + name: Run parsing tests with Go ${{ matrix.go }} + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go env + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + - name: Run tests + run: | + go version + go test -v -timeout 9999s -count 1 -p 1 -cover -coverprofile coverage.txt ./ + - name: Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + flags: parsing + name: parsing + + TestLocal: + runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.18', 'oldstable', 'stable' ] + name: Run tests against local AWS DynamoDB with Go ${{ matrix.go }} + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go env + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + - name: Start local AWS DynamoDB server + run: docker run -d --name dynamodb -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -inMemory -sharedDb + - name: Run tests + run: | + go version + cd module_test \ + && go test -v -timeout 9999s -count 1 -p 1 -cover -coverpkg="${COVER_PKG}" -coverprofile coverage_local.txt ./ \ + && cd .. + - name: Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + flags: other + name: other