Skip to content

Commit

Permalink
CI: rework GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
btnguyen2k committed Dec 27, 2023
1 parent 785068f commit 92fe411
Showing 1 changed file with 111 additions and 23 deletions.
134 changes: 111 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 92fe411

Please sign in to comment.