From f49a4e8adc81f86553f3837c6cfa6823089f32e4 Mon Sep 17 00:00:00 2001 From: BeyondRobot Date: Wed, 22 Sep 2021 11:47:33 +0800 Subject: [PATCH] ci: Sync github actions (#57) * Delete not allowed file: .github/workflows/diff-check.yml * Delete not allowed file: .github/workflows/gofmt.yml * Delete not allowed file: .github/workflows/auto-build.yml * Delete not allowed file: .github/workflows/codeql-analysis.yml * Add new file: .github/workflows/build-test.yml * Add new file: .github/workflows/unit-test.yml * Add new file: .github/workflows/auto-merge.yml --- .../{auto-build.yml => auto-merge.yml} | 10 ++- .../{diff-check.yml => build-test.yml} | 11 +-- .github/workflows/codeql-analysis.yml | 71 ------------------- .github/workflows/gofmt.yml | 20 ------ .github/workflows/unit-test.yml | 4 +- 5 files changed, 17 insertions(+), 99 deletions(-) rename .github/workflows/{auto-build.yml => auto-merge.yml} (83%) rename .github/workflows/{diff-check.yml => build-test.yml} (67%) delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/gofmt.yml diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-merge.yml similarity index 83% rename from .github/workflows/auto-build.yml rename to .github/workflows/auto-merge.yml index 4aed6de..e0881aa 100644 --- a/.github/workflows/auto-build.yml +++ b/.github/workflows/auto-merge.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: "1.15" + go-version: "1.16" - name: Checkout repository uses: actions/checkout@v2 @@ -42,8 +42,14 @@ jobs: with: commit_message: Auto build to generate code - - name: Enable auto-merge for dependabot PRs + - name: Auto merge run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ secrets.ROBOT_GITHUB_TOKEN }} + + - name: Auto approve + run: gh pr review "$PR_URL" -a + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.ROBOT_GITHUB_TOKEN }} diff --git a/.github/workflows/diff-check.yml b/.github/workflows/build-test.yml similarity index 67% rename from .github/workflows/diff-check.yml rename to .github/workflows/build-test.yml index 951bb64..26c30f5 100644 --- a/.github/workflows/diff-check.yml +++ b/.github/workflows/build-test.yml @@ -1,21 +1,24 @@ -name: "diff-check" +name: "Build Test" on: [ push,pull_request ] jobs: - diff-check: - name: diff-check + build_test: + name: Build Test runs-on: ubuntu-latest steps: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: "1.15" + go-version: "1.16" - name: Checkout repository uses: actions/checkout@v2 + - name: Format + run: if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then exit 1; fi + - name: Build run: make build diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index cc09913..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,71 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -name: "CodeQL" - -on: - push: - branches: [master] - pull_request: - # The branches below must be a subset of the branches above - branches: [master] - schedule: - - cron: '0 13 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['go'] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - 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@v1 - - # ℹī¸ 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@v1 diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml deleted file mode 100644 index 4c073c9..0000000 --- a/.github/workflows/gofmt.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "gofmt" - -on: [ push,pull_request ] - -jobs: - gofmt: - name: gofmt - runs-on: ubuntu-latest - - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: "1.15" - - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Format - run: if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then exit 1; fi diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index eeb0bc8..cb8b384 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -1,6 +1,6 @@ name: "Unit Test" -on: [push,pull_request] +on: [ push,pull_request ] jobs: unit_test: @@ -10,7 +10,7 @@ jobs: strategy: matrix: go: [ "1.15", "1.16" ] - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - name: Set up Go 1.x