diff --git a/.github/workflows/autoformat.yml b/.github/workflows/autoformat.yml deleted file mode 100644 index cb2e1aa..0000000 --- a/.github/workflows/autoformat.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Code Formatter -on: - pull_request: - types: - - labeled -jobs: - autoformat: - runs-on: ubuntu-latest - if: contains(github.event.pull_request.labels.*.name, 'autoformat') - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: '^1.14' - - name: Install goimports - run: go get golang.org/x/tools/cmd/goimports - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.ref }} - - run: goimports -w . - - run: go mod tidy - - name: Commit changes - env: - GITHUB_TOKEN: ${{ secrets.FORMAT_TOKEN }} - run: | - git config user.name yoshi-automation - git config user.email yoshi-automation@google.com - git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git - git add . - if [ -n "$(git status --porcelain)" ]; then - git commit --author "yoshi-automation " --message "Run goimports and go mod tidy" - git push - fi - - name: Remove autoformat label - uses: actions/github-script@v2 - with: - github-token: ${{secrets.FORMAT_TOKEN}} - script: | - github.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - name: 'autoformat' - }) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb8e6d2..b08fedd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,29 +10,26 @@ jobs: lint: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: '^1.18' + go-version: 'stable' - name: Install goimports run: go install golang.org/x/tools/cmd/goimports@latest - - name: Checkout code - uses: actions/checkout@v3 - run: goimports -w . - run: go mod tidy # If there are any diffs from goimports or go mod tidy, fail. - name: Verify no changes from goimports and go mod tidy run: | if [ -n "$(git status --porcelain)" ]; then + git status --porcelain exit 1 fi test: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: '^1.18' - - name: Checkout code - uses: actions/checkout@v2 + go-version: 'stable' - run: go test ./...