Merge pull request #9 from tkc/feat/modernize-infrastructure #78
This file contains hidden or 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: sql-dog | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| test: | |
| name: Build and Test | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: admin | |
| MYSQL_DATABASE: sql-dog | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd "mysqladmin ping -h localhost" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.22' | |
| cache: true | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| go mod download | |
| go get github.com/goccy/go-yaml | |
| go get github.com/bxcodec/faker/v3 | |
| - name: Run tests and linting | |
| run: | | |
| # Basic format check instead of using golangci-lint | |
| gofmt -l . | grep -v vendor/ | tee /dev/stderr | (! grep .) | |
| # Run tests | |
| go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | |
| env: | |
| DB_HOST: localhost | |
| DB_PORT: 3306 | |
| DB_USER: root | |
| DB_PASSWORD: admin | |
| DB_NAME: sql-dog | |
| - name: Upload coverage report | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| files: ./coverage.txt | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false |