github.com/icyphox/x@v0.0.355-0.20220311094250-029bd783e8b8/.github/workflows/test.yml (about)

     1  name: "Run Tests and Lint Code"
     2  
     3  on:
     4    push:
     5      branches:
     6        - master
     7    pull_request:
     8      branches:
     9        - master
    10  
    11  jobs:
    12    test-windows:
    13      name: Run Tests on Windows
    14      runs-on: windows-latest
    15      steps:
    16        - run: |
    17            git config --system core.autocrlf false
    18            git config --system core.eol lf
    19        - uses: actions/checkout@v2
    20        - uses: actions/setup-go@v2
    21          with:
    22            go-version: '^1.16'
    23        - run: |
    24            go test -tags sqlite -failfast -short -timeout=20m $(go list ./... | grep -v sqlcon | grep -v watcherx | grep -v pkgerx | grep -v configx)
    25          shell: bash
    26    test:
    27      name: Run Tests and Lint Code
    28      runs-on: ubuntu-latest
    29      env:
    30        TEST_DATABASE_POSTGRESQL: postgres://test:test@localhost:5432/sqlcon?sslmode=disable
    31        TEST_DATABASE_MYSQL: mysql://root:test@tcp(localhost:3306)/mysql?parseTime=true&multiStatements=true
    32        TEST_DATABASE_COCKROACHDB: cockroach://root@localhost:26257/defaultdb?sslmode=disable
    33      services:
    34        postgres:
    35          image: postgres:11.8
    36          ports:
    37            - 5432:5432
    38          env:
    39            POSTGRES_USER: test
    40            POSTGRES_PASSWORD: test
    41            POSTGRES_DB: sqlcon
    42        mysql:
    43          image: mysql:8.0
    44          ports:
    45            - 3306:3306
    46          env:
    47            MYSQL_ROOT_PASSWORD: test
    48      steps:
    49        - name: Start cockroach
    50          run: docker run --name cockroach -p 26257:26257 -d cockroachdb/cockroach:v20.2.5 start-single-node --insecure
    51        - name: Checkout repository
    52          uses: actions/checkout@v2
    53        - uses: actions/setup-go@v2
    54          with:
    55            go-version: '^1.16.0'
    56        - name: golangci-lint
    57          uses: golangci/golangci-lint-action@v3
    58          with:
    59            skip-go-installation: true
    60            args: --timeout 2m
    61        - name: Install cockroach DB
    62          run: |
    63            curl https://binaries.cockroachdb.com/cockroach-v21.1.2.linux-amd64.tgz | tar -xz
    64            sudo cp -i cockroach-v21.1.2.linux-amd64/cockroach /usr/local/bin/
    65            rm -rf cockroach-v21.1.2.linux-amd64
    66        - name: Prepare nancy dependency list
    67          run: go list -json -deps > go.list
    68        - name: Run nancy
    69          uses: sonatype-nexus-community/nancy-github-action@main
    70        - run: make .bin/go-acc .bin/gcov2lcov
    71        - run: COCKROACH_BINARY=cockroach .bin/go-acc -o coverage.out ./... -- -v -failfast -timeout=20m -tags sqlite
    72        - name: Convert coverage report to lcov
    73          run: .bin/gcov2lcov -infile=coverage.out -outfile=coverage.lcov
    74        - name: Coveralls
    75          uses: coverallsapp/github-action@master
    76          with:
    77            github-token: ${{ secrets.GITHUB_TOKEN }}
    78            path-to-lcov: coverage.lcov
    79  
    80    release:
    81      name: Release a new version
    82      if: github.ref == 'refs/heads/master'
    83      runs-on: ubuntu-latest
    84      steps:
    85        - name: Checkout repository
    86          uses: actions/checkout@v2
    87          with:
    88            fetch-depth: '0'
    89        - uses: actions/setup-node@v2
    90          with:
    91            node-version: '14'
    92        - name: Define next tag
    93          run: npx semver -- $(git describe --tags `git rev-list --tags --max-count=1`)
    94        - name: Create git tag
    95          run: |
    96            git tag "v$(npx semver -- $(git describe --tags `git rev-list --tags --max-count=1`) --increment=patch)"
    97        - name: Push git tag
    98          run: git push --tags