Skip to content

Optimize workflow and up golang version #203

Optimize workflow and up golang version

Optimize workflow and up golang version #203

Workflow file for this run

on:
push:
branches:
- main
pull_request:
branches:
- main
name: Test
env:
GO_TARGET_VERSION: 1.21
OS_TARGET: ubuntu-latest
jobs:
tests:
env:
RUN_INTEGRATION_TEST: ${{ matrix.go-version == env.GO_TARGET_VERSION && matrix.os == env.OS_TARGET }}

Check failure on line 15 in .github/workflows/main.yaml

View workflow run for this annotation

GitHub Actions / Test

Invalid workflow file

The workflow is not valid. .github/workflows/main.yaml (Line: 15, Col: 29): Unrecognized named-value: 'env'. Located at position 22 within expression: matrix.go-version == env.GO_TARGET_VERSION && matrix.os == env.OS_TARGET .github/workflows/main.yaml (Line: 20, Col: 16): Unrecognized named-value: 'env'. Located at position 10 within expression: fromJSON(env.RUN_INTEGRATION_TEST) && 'redis' || ''
permissions:
pull-requests: write
services:
redis:
image: ${{ fromJSON(env.RUN_INTEGRATION_TEST) && 'redis' || '' }}
ports:
- 6379:6379
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: ${{ fromJSON(env.RUN_INTEGRATION_TEST) && 'postgres' || '' }}
env:
POSTGRES_DB: db
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
go-version:
# - '1.10' doesn't have go module
# - 1.11
# - 1.12 doesn't have errors pkg
- 1.13
- 1.14
- 1.15
- 1.16
- 1.17
- 1.18
- 1.19
- 1.20
- 1.21
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
mongodb-version:
- '6.0'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}
- name: Start MongoDB
if: ${{ fromJSON(env.RUN_INTEGRATION_TEST) }}
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs
- name: Tests
if: ${{ !fromJSON(env.RUN_INTEGRATION_TEST) }}
run: make test
- name: Tests with real databases
if: ${{ fromJSON(env.RUN_INTEGRATION_TEST) }}
run: make test.coverage.with_real_db
- name: Code coverage data
if: ${{ fromJSON(env.RUN_INTEGRATION_TEST) }}
run: |
set -x
COVERAGE_TOTAL=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "COVERAGE_TOTAL=$COVERAGE_TOTAL" >> $GITHUB_ENV
- uses: jandelgado/[email protected]
if: ${{ fromJSON(env.NEED_CODECOVERAGE) }}
with:
outfile: ./coverage.lcov
- name: Coveralls
uses: coverallsapp/github-action@master
if: ${{ fromJSON(env.NEED_CODECOVERAGE) }}
with:
path-to-lcov: ./coverage.lcov
github-token: ${{ secrets.GITHUB_TOKEN }}
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_TARGET_VERSION }}
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=3m -v