diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fc709df..051dc65 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -21,9 +21,6 @@ on: schedule: - cron: '33 10 * * 6' -env: - GO_VERSION: 1.21.x - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -45,40 +42,13 @@ jobs: # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - if: ${{ matrix.language == 'go' }} + - name: Setup + uses: nhatthm/gh-actions/find-go-version@master with: - go-version: ${{ env.GO_VERSION }} + go-version-file: "" - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + - name: Run CodeQL + uses: nhatthm/gh-actions/codeql@master with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + language: ${{ matrix.language }} + go-version: ${{ env.GO_LATEST_VERSION }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e1a8311..e6ce04a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -6,9 +6,6 @@ on: branches: - master -env: - GO_VERSION: 1.21.x - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -22,21 +19,20 @@ jobs: module: [ ".", "tests/suite", "tests/mssql", "tests/mysql", "tests/postgres" ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master + + - name: Setup + uses: nhatthm/gh-actions/find-go-version@master - name: Install Go - uses: actions/setup-go@v5 + uses: nhatthm/gh-actions/setup-go@master with: - go-version: ${{ env.GO_VERSION }} - - - id: vars - run: | - make $GITHUB_OUTPUT + go-version: ${{ env.GO_LATEST_VERSION }} - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + - name: Lint + uses: nhatthm/gh-actions/golangci-lint@master with: - version: ${{ steps.vars.outputs.GOLANGCI_LINT_VERSION }} working-directory: ${{ matrix.module }} args: --timeout=5m @@ -44,10 +40,11 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master - - name: gherkin-lint - uses: nhatthm/gherkin-lint-action@v1.0.0 + - name: Lint + uses: nhatthm/gh-actions/gherkin-lint@master with: feature_files: tests/features/* config_file: tests/.gherkin-lintrc diff --git a/.github/workflows/pr-tidy.yaml b/.github/workflows/pr-tidy.yaml index 70c21b3..a43b434 100644 --- a/.github/workflows/pr-tidy.yaml +++ b/.github/workflows/pr-tidy.yaml @@ -17,37 +17,27 @@ jobs: runs-on: ubuntu-latest if: ${{ startsWith(github.head_ref, 'dependabot/go_modules/') }} steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master with: token: ${{ secrets.PUSH_TOKEN }} ref: ${{ github.head_ref }} - - name: Go cache - uses: actions/cache@v4 + - name: Find Go version + uses: nhatthm/gh-actions/find-go-version@master + + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ env.GO_VERSION }}-cache + go-version: ${{ env.GO_VERSION }} - name: Tidy run: | make tidy - - name: setup-gpg + - name: Setup GPG id: setup-gpg - uses: crazy-max/ghaction-import-gpg@v6 + uses: nhatthm/gh-actions/import-gpg@master with: gpg_private_key: ${{ secrets.PUSH_PRIVATE_KEY }} passphrase: ${{ secrets.PUSH_SECRET }} @@ -56,7 +46,8 @@ jobs: git_commit_gpgsign: true git_tag_gpgsign: false - - uses: EndBug/add-and-commit@v9 + - name: Add and Commit + uses: nhatthm/gh-actions/git-add-and-commit@master with: message: "go mod tidy" push: true diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 7a2987b..9603dc6 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -6,45 +6,47 @@ on: env: GO111MODULE: "on" - GO_VERSION: 1.20.x - GO_LATEST_VERSION: "1.21.x" concurrency: group: ${{ github.workflow }}-${{ github.head_ref }} cancel-in-progress: true jobs: + setup: + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.find-go-version.outputs.go-version }} + go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }} + go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }} + steps: + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master + + - id: find-go-version + name: Find Go version + uses: nhatthm/gh-actions/find-go-version@master + precondition: name: precondition + needs: [setup] outputs: passed: ${{ steps.check.outputs.passed == '' && 'true' || steps.check.outputs.passed }} runs-on: ubuntu-latest env: IS_DEPENDABOT_PR: ${{ startsWith(github.head_ref, 'dependabot/go_modules/') && 'true' || 'false' }} + GO_VERSION: ${{ needs.setup.outputs.go-version }} + GO_LATEST_VERSION: ${{ needs.setup.outputs.go-latest-version }} steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master if: ${{ env.IS_DEPENDABOT_PR == 'true' }} - name: Install Go - uses: actions/setup-go@v5 + uses: nhatthm/gh-actions/setup-go@master if: ${{ env.IS_DEPENDABOT_PR == 'true' }} with: go-version: ${{ env.GO_VERSION }} - - name: Go cache - uses: actions/cache@v4 - if: ${{ env.IS_DEPENDABOT_PR == 'true' }} - with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ env.GO_VERSION }}-cache - - id: check if: ${{ env.IS_DEPENDABOT_PR == 'true' }} run: .github/scripts/pr_precondition.sh @@ -56,24 +58,23 @@ jobs: matrix: module: [ ".", "tests/suite", "tests/mssql", "tests/mysql", "tests/postgres" ] runs-on: ubuntu-latest - needs: precondition + needs: [setup, precondition] + env: + GO_VERSION: ${{ needs.setup.outputs.go-version }} + GO_LATEST_VERSION: ${{ needs.setup.outputs.go-latest-version }} if: ${{ needs.precondition.outputs.passed == 'true' }} steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master - name: Install Go - uses: actions/setup-go@v5 + uses: nhatthm/gh-actions/setup-go@master with: - go-version: ${{ env.GO_VERSION }} - - - id: vars - run: | - make $GITHUB_OUTPUT + go-version: ${{ env.GO_LATEST_VERSION }} - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + - name: Lint + uses: nhatthm/gh-actions/golangci-lint@master with: - version: ${{ steps.vars.outputs.GOLANGCI_LINT_VERSION }} working-directory: ${{ matrix.module }} args: --timeout=5m @@ -83,10 +84,11 @@ jobs: needs: precondition if: ${{ needs.precondition.outputs.passed == 'true' }} steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master - - name: gherkin-lint - uses: nhatthm/gherkin-lint-action@v1.0.0 + - name: Lint + uses: nhatthm/gh-actions/gherkin-lint@master with: feature_files: tests/features/* config_file: tests/.gherkin-lintrc @@ -96,35 +98,22 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] exclude: - os: macos-latest arch: "386" runs-on: ${{ matrix.os }} - needs: precondition + needs: [setup, precondition] if: ${{ needs.precondition.outputs.passed == 'true' }} steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-cache + go-version: ${{ matrix.go-version }} - name: Test id: test @@ -135,7 +124,7 @@ jobs: - name: Upload code coverage (unit) if: ${{ matrix.go-version == env.GO_LATEST_VERSION }} - uses: codecov/codecov-action@v3 + uses: nhatthm/gh-actions/codecov@master with: files: ./unit.coverprofile flags: unittests-${{ runner.os }}-${{ runner.arch }} @@ -144,32 +133,21 @@ jobs: strategy: fail-fast: false matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] mssql-version: [ "2019" ] runs-on: ubuntu-latest - needs: test-unit + needs: [setup, test-unit] steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache + go-version: ${{ matrix.go-version }} + cache-key: ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache-${{ hashFiles('**/go.sum') }} + cache-restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache - name: Test id: test @@ -183,32 +161,21 @@ jobs: strategy: fail-fast: false matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] mysql-version: [ "8" ] runs-on: ubuntu-latest - needs: test-unit + needs: [setup, test-unit] steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache + go-version: ${{ matrix.go-version }} + cache-key: ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache-${{ hashFiles('**/go.sum') }} + cache-restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache - name: Test id: test @@ -222,33 +189,22 @@ jobs: strategy: fail-fast: false matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] postgres-version: [ "12", "13", "14", "15", "16" ] postgres-driver: [ "postgres", "pgx/v4", "pgx/v5" ] runs-on: ubuntu-latest - needs: test-unit + needs: [setup, test-unit] steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache + go-version: ${{ matrix.go-version }} + cache-key: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache-${{ hashFiles('**/go.sum') }} + cache-restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache - name: Test id: test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6c1eeb3..6389d73 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,8 @@ jobs: name: release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master with: token: ${{ secrets.RELEASE_TOKEN }} ref: master @@ -24,9 +25,9 @@ jobs: - name: set-version run: .github/scripts/set_version.sh "${{ github.event.inputs.version }}" - - name: setup-gpg + - name: Setup GPG id: setup-gpg - uses: crazy-max/ghaction-import-gpg@v6 + uses: nhatthm/gh-actions/import-gpg@master with: gpg_private_key: ${{ secrets.RELEASE_PRIVATE_KEY }} passphrase: ${{ secrets.RELEASE_SECRET }} @@ -35,7 +36,8 @@ jobs: git_commit_gpgsign: true git_tag_gpgsign: false - - uses: EndBug/add-and-commit@v9 + - name: Add and Commit + uses: nhatthm/gh-actions/git-add-and-commit@master with: add: version.go message: "Release ${{ env.VERSION }}" @@ -46,7 +48,7 @@ jobs: committer_name: ${{ steps.setup-gpg.outputs.name }} committer_email: ${{ steps.setup-gpg.outputs.email }} - - uses: softprops/action-gh-release@v1 + - uses: nhatthm/gh-actions/github-release@master with: name: "${{ env.VERSION }}" tag_name: "${{ env.VERSION }}" diff --git a/.github/workflows/test-compatibility-libpq.yaml b/.github/workflows/test-compatibility-libpq.yaml index 41e0014..8bdd1a4 100644 --- a/.github/workflows/test-compatibility-libpq.yaml +++ b/.github/workflows/test-compatibility-libpq.yaml @@ -14,35 +14,39 @@ concurrency: cancel-in-progress: true jobs: + setup: + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.find-go-version.outputs.go-version }} + go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }} + go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }} + steps: + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master + + - id: find-go-version + name: Find Go version + uses: nhatthm/gh-actions/find-go-version@master + test: strategy: fail-fast: false matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] postgres-version: [ "12", "13", "14", "15", "16" ] runs-on: ubuntu-latest + needs: [setup] steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache + go-version: ${{ matrix.go-version }} + cache-key: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache-${{ hashFiles('**/go.sum') }} + cache-restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache - name: Test id: test diff --git a/.github/workflows/test-compatibility-mssql.yaml b/.github/workflows/test-compatibility-mssql.yaml index 30810af..fa801e9 100644 --- a/.github/workflows/test-compatibility-mssql.yaml +++ b/.github/workflows/test-compatibility-mssql.yaml @@ -14,35 +14,39 @@ concurrency: cancel-in-progress: true jobs: + setup: + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.find-go-version.outputs.go-version }} + go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }} + go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }} + steps: + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master + + - id: find-go-version + name: Find Go version + uses: nhatthm/gh-actions/find-go-version@master + test: strategy: fail-fast: false matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] mssql-version: [ "2019" ] runs-on: ubuntu-latest + needs: [setup] steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache + go-version: ${{ matrix.go-version }} + cache-key: ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache-${{ hashFiles('**/go.sum') }} + cache-restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-mssql-cache - name: Test id: test diff --git a/.github/workflows/test-compatibility-mysql.yaml b/.github/workflows/test-compatibility-mysql.yaml index 9e2f116..ab02294 100644 --- a/.github/workflows/test-compatibility-mysql.yaml +++ b/.github/workflows/test-compatibility-mysql.yaml @@ -14,35 +14,39 @@ concurrency: cancel-in-progress: true jobs: + setup: + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.find-go-version.outputs.go-version }} + go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }} + go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }} + steps: + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master + + - id: find-go-version + name: Find Go version + uses: nhatthm/gh-actions/find-go-version@master + test: strategy: fail-fast: false matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] mysql-version: [ "8" ] runs-on: ubuntu-latest + needs: [setup] steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache + go-version: ${{ matrix.go-version }} + cache-key: ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache-${{ hashFiles('**/go.sum') }} + cache-restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-mysql-cache - name: Test id: test diff --git a/.github/workflows/test-compatibility-pgx.yaml b/.github/workflows/test-compatibility-pgx.yaml index f31066e..a2282f9 100644 --- a/.github/workflows/test-compatibility-pgx.yaml +++ b/.github/workflows/test-compatibility-pgx.yaml @@ -14,36 +14,40 @@ concurrency: cancel-in-progress: true jobs: + setup: + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.find-go-version.outputs.go-version }} + go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }} + go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }} + steps: + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master + + - id: find-go-version + name: Find Go version + uses: nhatthm/gh-actions/find-go-version@master + test: strategy: fail-fast: false matrix: - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] postgres-version: [ "12", "13", "14", "15", "16" ] pgx-version: [ "v4", "v5"] runs-on: ubuntu-latest + needs: [setup] steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache + go-version: ${{ matrix.go-version }} + cache-key: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache-${{ hashFiles('**/go.sum') }} + cache-restore-keys: ${{ runner.os }}-go-${{ matrix.go-version }}-postgres-cache - name: Test id: test diff --git a/.github/workflows/test-unit.yaml b/.github/workflows/test-unit.yaml index 46a7a83..4a86f9e 100644 --- a/.github/workflows/test-unit.yaml +++ b/.github/workflows/test-unit.yaml @@ -8,45 +8,48 @@ on: env: GO111MODULE: "on" - GO_LATEST_VERSION: "1.21.x" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: + setup: + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.find-go-version.outputs.go-version }} + go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }} + go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }} + steps: + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master + + - id: find-go-version + name: Find Go version + uses: nhatthm/gh-actions/find-go-version@master + test: strategy: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - go-version: [ 1.20.x, 1.21.x ] + go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }} arch: [ "386", amd64 ] exclude: - os: macos-latest arch: "386" runs-on: ${{ matrix.os }} + needs: [setup] + env: + GO_LATEST_VERSION: ${{ needs.setup.outputs.go-latest-version }} steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 + uses: nhatthm/gh-actions/checkout@master - - name: Go cache - uses: actions/cache@v4 + - name: Install Go + uses: nhatthm/gh-actions/setup-go@master with: - # In order: - # * Module download cache - # * Build cache (Linux) - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-go-${{ matrix.go-version }}-cache-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ matrix.go-version }}-cache + go-version: ${{ matrix.go-version }} - name: Test id: test @@ -57,7 +60,7 @@ jobs: - name: Upload code coverage (unit) if: ${{ matrix.go-version == env.GO_LATEST_VERSION }} - uses: codecov/codecov-action@v3 + uses: nhatthm/gh-actions/codecov@master with: files: ./unit.coverprofile flags: unittests-${{ runner.os }}-${{ runner.arch }} diff --git a/.github/workflows/update-registry.yaml b/.github/workflows/update-registry.yaml index d3cc60a..013492f 100644 --- a/.github/workflows/update-registry.yaml +++ b/.github/workflows/update-registry.yaml @@ -12,21 +12,11 @@ on: jobs: notify: runs-on: ubuntu-latest - strategy: - matrix: - registry: [ go.nhat.io, go-staging.nhat.io ] steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: nhatthm/gh-actions/checkout@master - - id: vars - run: | - make $GITHUB_OUTPUT - - - name: notify ${{ matrix.registry }} - uses: benc-uk/workflow-dispatch@v121 + - name: Notify registries + uses: nhatthm/gh-actions/notify-go-registries@master with: - workflow: build - repo: nhatthm/${{ matrix.registry }} token: ${{ secrets.REGISTRY_TOKEN }} - inputs: '{"modules": "${{ steps.vars.outputs.MODULE_NAME }}"}' - ref: 'master'