From ff0ff65d07abd39d68e74a6d584be92be7ce51ff Mon Sep 17 00:00:00 2001 From: Sam Coe Date: Mon, 9 May 2022 18:48:45 +0200 Subject: [PATCH] Update test and lint workflow files (#38) --- .github/workflows/codeql-analysis.yml | 78 +++++++-------------------- .github/workflows/lint.yml | 34 ++++++++++-- .github/workflows/test.yml | 8 +-- 3 files changed, 54 insertions(+), 66 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 27a7fe4..3133a1a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,70 +1,28 @@ -# 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. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - +name: Code Scanning on: push: - branches: [ trunk ] + branches: [trunk] pull_request: - # The branches below must be a subset of the branches above - branches: [ trunk ] + branches: [trunk] schedule: - - cron: '41 10 * * 2' - + - cron: '0 0 * * 0' +permissions: + actions: read + contents: read + security-events: write jobs: - analyze: - name: Analyze + CodeQL-Build: runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'go' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # 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 + - name: Checkout repository + uses: actions/checkout@v3 - #- run: | - # make bootstrap - # make release + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: go + queries: security-and-quality - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6c13706..01c6ff0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,29 @@ name: Lint on: [push, pull_request] +permissions: + contents: read jobs: + go-mod: + strategy: + matrix: + os: [ubuntu-latest] + go: [1.16] + runs-on: ${{ matrix.os }} + + steps: + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check go mod + run: | + go mod tidy + git diff --exit-code go.mod + lint: strategy: matrix: @@ -9,10 +32,15 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + + - name: Checkout repository + uses: actions/checkout@v3 - name: Lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3.1.0 with: version: latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 000f7da..37bdea1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,7 @@ name: Test on: [push, pull_request] +permissions: + contents: read jobs: test: strategy: @@ -11,12 +13,12 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v3 - name: Run tests run: go test -v ./...