From 178152d5104da02bfbb243dd370415750841e123 Mon Sep 17 00:00:00 2001 From: Alexandre Nicolaie Date: Mon, 18 Dec 2023 22:29:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20(workflows):=20Rewrite=20Github?= =?UTF-8?q?=20workflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update all GH workflows following the beluga-cloud naming convention. Also add CodeQL and add some lint. --- .../pull_request,push,schedule.codeql.yaml | 70 +++++++++++++++++++ .../workflows/pull_request,push.go.lint.yaml | 19 +++++ ...go.yaml => pull_request,push.go.test.yaml} | 27 +++---- ...l => pull_request.security.workflows.yaml} | 0 ...repo.labels.yaml => push.repo.labels.yaml} | 2 +- 5 files changed, 98 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/pull_request,push,schedule.codeql.yaml create mode 100644 .github/workflows/pull_request,push.go.lint.yaml rename .github/workflows/{go.yaml => pull_request,push.go.test.yaml} (56%) rename .github/workflows/{security.workflows.yaml => pull_request.security.workflows.yaml} (100%) rename .github/workflows/{repo.labels.yaml => push.repo.labels.yaml} (86%) diff --git a/.github/workflows/pull_request,push,schedule.codeql.yaml b/.github/workflows/pull_request,push,schedule.codeql.yaml new file mode 100644 index 00000000..6145a6e9 --- /dev/null +++ b/.github/workflows/pull_request,push,schedule.codeql.yaml @@ -0,0 +1,70 @@ +name: "CodeQL" + +on: + pull_request: + branches: [main] + push: + branches: [main] + schedule: + - cron: '31 14 * * 6' + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # renovate: tag=v3.0.2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@b374143c1149a9115d881581d29b8390bbcbb59c # renovate: tag=v3.22.1 + 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. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@b374143c1149a9115d881581d29b8390bbcbb59c # renovate: tag=v3.22.1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@b374143c1149a9115d881581d29b8390bbcbb59c # renovate: tag=v3.22.1 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/pull_request,push.go.lint.yaml b/.github/workflows/pull_request,push.go.lint.yaml new file mode 100644 index 00000000..f9cf1dc9 --- /dev/null +++ b/.github/workflows/pull_request,push.go.lint.yaml @@ -0,0 +1,19 @@ +name: Lint code (Go) +on: + pull_request: + paths: + - "**/*.go" + - .github/workflows/pull_request,push.go.lint.yaml + +jobs: + golangci-lint: + name: golanci-lint + permissions: + contents: read + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # renovate: tag=v3.2.0 + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # renovate: tag=v3.0.2 + - uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # renovate: tag=v3.2.0 + with: + version: latest diff --git a/.github/workflows/go.yaml b/.github/workflows/pull_request,push.go.test.yaml similarity index 56% rename from .github/workflows/go.yaml rename to .github/workflows/pull_request,push.go.test.yaml index 4ef696dd..d0a8097c 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/pull_request,push.go.test.yaml @@ -1,32 +1,21 @@ -name: Go +name: Test code (Go) on: pull_request: - paths: [cmd/**, pkg/**, go.mod, go.sum, .github/workflows/go.yaml] + paths: + - "**/*.go" + - go.mod + - go.sum + - .github/workflows/pull_request,push.go.test.yaml push: branches: [main] - paths: [cmd/**, pkg/**, go.mod, go.sum, .github/workflows/go.yaml] jobs: - lint: - name: Lint - permissions: - contents: read - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # renovate: tag=v3.2.0 - with: - go-version: 1.18 - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # renovate: tag=v3.0.2 - - uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # renovate: tag=v3.2.0 - with: - version: latest - test: - name: Test + name: Go test runs-on: ${{ matrix.os }} strategy: matrix: - go: [1.18] + go: [1.21] os: [ubuntu-latest, macos-latest] steps: - uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923 # renovate: tag=v3.2.0 diff --git a/.github/workflows/security.workflows.yaml b/.github/workflows/pull_request.security.workflows.yaml similarity index 100% rename from .github/workflows/security.workflows.yaml rename to .github/workflows/pull_request.security.workflows.yaml diff --git a/.github/workflows/repo.labels.yaml b/.github/workflows/push.repo.labels.yaml similarity index 86% rename from .github/workflows/repo.labels.yaml rename to .github/workflows/push.repo.labels.yaml index 6d956c7c..55736ad0 100644 --- a/.github/workflows/repo.labels.yaml +++ b/.github/workflows/push.repo.labels.yaml @@ -2,7 +2,7 @@ name: Synchronize labels on: push: branches: [main] - paths: [.github/workflows/github.labeler.yaml, .github/labels.yaml] + paths: [.github/workflows/push.repo.labels.yaml, .github/labels.yaml] jobs: sync: