Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 (trunk): Add Trunk integration for this project #66

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/merge_group,pull_request,schedule.codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CodeQL

on:
merge_group: {}
pull_request: {}
schedule:
- cron: 31 14 * * 6

permissions: read-all

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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install Golang
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # renovate: tag=v5.0.0
with:
go-version-file: go.mod

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3
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@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3
with:
category: "/language:${{matrix.language}}"
17 changes: 17 additions & 0 deletions .github/workflows/merge_group,pull_request.all.lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Lint everything (Trunk)

on:
merge_group: {}
pull_request: {}

permissions: read-all

jobs:
trunk:
name: Trunk Check
permissions:
checks: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: trunk-io/trunk-action@97ecd21fe6c743bf7a606791584b683a7995c70e # v1.1.9
37 changes: 37 additions & 0 deletions .github/workflows/merge_group,pull_request.go.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test code (Go)
on:
merge_group: {}
pull_request:
paths:
- "**/*.go"
- go.mod
- go.sum
- .github/workflows/pull_request,push.go.test.yaml

permissions: read-all

jobs:
test:
name: Go test
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: [1.21]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # renovate: tag=v5.0.0
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: go test -v -race -covermode=atomic -coverprofile=coverage.out ./...
- uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
env:
OS: ${{ matrix.os }}
GO_VERSION: ${{ matrix.go }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
env_vars: GO_VERSION
fail_ci_if_error: true
flags: unittests
verbose: true
75 changes: 0 additions & 75 deletions .github/workflows/pull_request,push,schedule.codeql.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/pull_request,push.go.lint.yaml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/pull_request,push.go.test.yaml

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/pull_request.security.workflows.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Security hardening (Github Actions workflows)

on:
merge_group: {}
pull_request:
types: [opened, synchronize]
paths: [".github/workflows/**"]
paths: [.github/workflows/**]

permissions: read-all

jobs:
ci_harden_security:
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/push.repo.labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ on:
branches: [main]
paths: [.github/workflows/push.repo.labels.yaml, .github/labels.yaml]

permissions: read-all

jobs:
sync:
name: Synchronize labels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c # renovate: tag=v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
manifest: .github/labels.yaml
prune: true
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c # renovate: tag=v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
manifest: .github/labels.yaml
prune: true
21 changes: 21 additions & 0 deletions .github/workflows/push.trunk-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Refresh Trunk cache

on:
push:
branches: [main]
paths: [.trunk/trunk.yaml]

permissions: read-all

jobs:
trunk-cache:
name: Refresh Trunk cache
runs-on: ubuntu-latest
permissions:
actions: write

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: trunk-io/trunk-action@97ecd21fe6c743bf7a606791584b683a7995c70e # v1.1.9
with:
check-mode: populate_cache_only
19 changes: 0 additions & 19 deletions .lefthook.toml

This file was deleted.

1 change: 0 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
golang 1.22.0
lefthook 1.5.5
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
10 changes: 10 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
10 changes: 10 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
Loading
Loading