Skip to content

Commit

Permalink
👷 (workflows): Rewrite Github workflows
Browse files Browse the repository at this point in the history
Update all GH workflows following the beluga-cloud naming convention.
Also add CodeQL and add some lint.
  • Loading branch information
xunleii committed Dec 18, 2023
1 parent c836646 commit 178152d
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 20 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/pull_request,push,schedule.codeql.yaml
Original file line number Diff line number Diff line change
@@ -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}}"
19 changes: 19 additions & 0 deletions .github/workflows/pull_request,push.go.lint.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 178152d

Please sign in to comment.