Zh new release #93
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: Main (test, releases) | |
| on: | |
| # # Indicates I want to run this workflow on all branches, PR, and tags | |
| push: | |
| branches: ["master"] | |
| tags: ["*"] | |
| pull_request: | |
| branches: [ "*" ] | |
| # TiDB versions used in tests - single source of truth | |
| env: | |
| TIDB_VERSIONS: "6.1.0 6.5.3 7.1.5 7.5.2 8.1.0" | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| command: | |
| - make vet | |
| - make fmtcheck | |
| steps: | |
| - name: Checkout Git repo | |
| uses: actions/checkout@v4 | |
| - name: Running ${{ matrix.command }} | |
| run: ${{ matrix.command }} | |
| prepare-dependencies: | |
| name: Prepare Dependencies | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout Git repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: go.mod | |
| - name: Download Terraform | |
| run: | | |
| mkdir -p bin | |
| curl -sfL https://releases.hashicorp.com/terraform/1.5.6/terraform_1.5.6_linux_amd64.zip > bin/terraform.zip | |
| cd bin && unzip terraform.zip && rm terraform.zip && chmod +x terraform | |
| - name: Vendor Go dependencies | |
| run: go mod vendor | |
| - name: Cache TiUP components | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.tiup | |
| key: ${{ runner.os }}-tiup-components | |
| restore-keys: | | |
| ${{ runner.os }}-tiup- | |
| - name: Install TiUP | |
| run: | | |
| if ! command -v tiup &> /dev/null; then | |
| curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh | |
| fi | |
| echo "$HOME/.tiup/bin" >> $GITHUB_PATH | |
| - name: Pre-download TiDB versions | |
| run: | | |
| export PATH=$HOME/.tiup/bin:$PATH | |
| # Pre-download all TiDB versions from env.TIDB_VERSIONS (single source of truth) | |
| echo "Pre-downloading TiDB versions: ${{ env.TIDB_VERSIONS }}" | |
| for version in ${{ env.TIDB_VERSIONS }}; do | |
| echo "Pre-downloading TiDB components for v${version}..." | |
| tiup install tidb:v${version} || true | |
| tiup install pd:v${version} || true | |
| tiup install tikv:v${version} || true | |
| done | |
| echo "TiDB version pre-download complete" | |
| - name: Upload Terraform binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: terraform-binary | |
| path: bin/terraform | |
| retention-days: 1 | |
| - name: Upload vendor directory | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vendor-dir | |
| path: vendor/ | |
| retention-days: 1 | |
| compression-level: 6 | |
| tests: | |
| runs-on: ubuntu-22.04 | |
| needs: [prepare-dependencies] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - testversion5.6 | |
| - testversion5.7 | |
| - testversion8.0 | |
| - testpercona5.7 | |
| - testpercona8.0 | |
| - testmariadb10.3 | |
| - testmariadb10.8 | |
| - testmariadb10.10 | |
| # Track https://github.com/pingcap/tidb/tags | |
| # TiDB versions must match env.TIDB_VERSIONS: 6.1.0 6.5.3 7.1.5 7.5.2 8.1.0 | |
| - testtidb6.1.0 | |
| - testtidb6.5.3 | |
| # - testtidb6.5.10 | |
| - testtidb7.1.5 | |
| - testtidb7.5.2 | |
| - testtidb8.1.0 | |
| steps: | |
| - name: Checkout Git repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: go.mod | |
| - name: Download Terraform binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: terraform-binary | |
| path: bin/ | |
| - name: Download vendor directory | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: vendor-dir | |
| path: vendor/ | |
| - name: Make Terraform executable | |
| run: chmod +x bin/terraform | |
| - name: Cache apt packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: /var/cache/apt | |
| key: ${{ runner.os }}-apt-${{ hashFiles('**/.github/workflows/main.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt- | |
| - name: Install mysql client | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y --no-install-recommends mysql-client | |
| - name: Cache TiUP components | |
| if: contains(matrix.target, 'tidb') | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.tiup | |
| key: ${{ runner.os }}-tiup-components | |
| restore-keys: | | |
| ${{ runner.os }}-tiup- | |
| - name: Install TiUP (if not cached) | |
| if: contains(matrix.target, 'tidb') | |
| run: | | |
| if ! command -v tiup &> /dev/null; then | |
| curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh | |
| echo "$HOME/.tiup/bin" >> $GITHUB_PATH | |
| else | |
| echo "$HOME/.tiup/bin" >> $GITHUB_PATH | |
| fi | |
| - name: Run tests {{ matrix.target }} | |
| env: | |
| GOFLAGS: -mod=vendor | |
| run: make ${{ matrix.target }} | |
| # DISABLED to figure out GPG signing issue on Github Actions | |
| # possibly due to lack of TTY inside docker? | |
| # release: | |
| # name: Release | |
| # needs: [tests] | |
| # # Can't use non-semvar for the testing tag | |
| # # https://github.com/orgs/goreleaser/discussions/3708 | |
| # if: ( startsWith( github.ref, 'refs/tags/v' ) || | |
| # startsWith(github.ref, 'refs/tags/v0.0.0-rc') ) | |
| # runs-on: ubuntu-22.04 | |
| # steps: | |
| # - name: Checkout Git repo | |
| # uses: actions/checkout@v4 | |
| # # Goreleaser | |
| # - name: Set up Go | |
| # uses: actions/setup-go@v4 | |
| # - name: Run GoReleaser | |
| # uses: goreleaser/goreleaser-action@v6 | |
| # with: | |
| # distribution: goreleaser | |
| # version: '~> v2' | |
| # # Run goreleaser and ignore non-committed files (downloaded artifacts) | |
| # args: release --clean --skip=validate --verbose | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # terraform-provider-release: | |
| # needs: [release] | |
| # name: 'Terraform Provider Release' | |
| # uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/community.yml@v5 | |
| # secrets: | |
| # gpg-private-key: '${{ secrets.GPG_PRIVATE_KEY }}' | |
| # with: | |
| # setup-go-version-file: 'go.mod' |