Skip to content

Commit

Permalink
improve workflows for multi package strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneWerner87 committed Jan 15, 2024
1 parent be9e257 commit ea00cb3
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 138 deletions.
41 changes: 24 additions & 17 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,37 @@ on:
- ".github/dependabot.yml"

jobs:
golangci-lint:
set-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Generate Matrix
working-directory: .
id: generate-matrix
run: |
SUBDIRS=$(find . -maxdepth 1 -type d -not -name '.*' -not -name 'internal' | sed 's|./||' | tr '\n' ' ')
JSON_MATRIX=$(echo "$SUBDIRS" | jq -R -c -s 'split(" ")')
echo "::set-output name=matrix::$JSON_MATRIX"
shell: bash

- name: Set up Go
golangci-lint:
runs-on: ubuntu-latest
needs: set-matrix
strategy:
matrix:
directory: ${{fromJson(needs.set-matrix.outputs.matrix)}}
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.x'

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2

- name: Get directories to lint
run: |
REPO_ROOT=$(pwd)
go list -f '{{.Dir}}' -m > dirs.txt
sed -i "s|${REPO_ROOT}/||" dirs.txt
cat dirs.txt
- name: Run golangci-lint for each directory
run: |
while IFS= read -r dir; do
echo "Linting directory $dir"
(cd "$dir" && golangci-lint run --tests=false)
done < dirs.txt
- name: Run golangci-lint
working-directory: ./${{ matrix.directory }}
run: golangci-lint run --tests=false
134 changes: 55 additions & 79 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,60 @@
name: Gosec Security Scan

on:
push:
branches:
- "master"
- "main"
paths-ignore:
- "**.md"
- LICENSE
- ".github/ISSUE_TEMPLATE/*.yml"
- ".github/dependabot.yml"
pull_request:
branches:
- "*"
paths-ignore:
- "**.md"
- LICENSE
- ".github/ISSUE_TEMPLATE/*.yml"
- ".github/dependabot.yml"
push:
branches:
- "master"
- "main"
paths-ignore:
- "**.md"
- LICENSE
- ".github/ISSUE_TEMPLATE/*.yml"
- ".github/dependabot.yml"
pull_request:
branches:
- "*"
paths-ignore:
- "**.md"
- LICENSE
- ".github/ISSUE_TEMPLATE/*.yml"
- ".github/dependabot.yml"

jobs:
gosec-scan:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'oldstable'
check-latest: true
cache: false
- name: Install Gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Run Gosec (paseto)
working-directory: ./paseto
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (fiberzap)
working-directory: ./fiberzap
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (otelfiber)
working-directory: ./otelfiber
run: gosec -exclude-dir=example ./...
- name: Run Gosec (swagger)
working-directory: ./swagger
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (casbin)
working-directory: ./casbin
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (fibernewrelic)
working-directory: ./fibernewrelic
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (opafiber)
working-directory: ./opafiber
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (fiberi18n)
working-directory: ./fiberi18n
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (fiberzerolog)
working-directory: ./fiberzerolog
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (jwt)
working-directory: ./jwt
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (websocket)
working-directory: ./websocket
run: gosec -exclude-dir=internal ./...
# -----
- name: Run Gosec (fgprof)
working-directory: ./fgprof
run: gosec -exclude-dir=internal ./...
# -----
set-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Generate Matrix
working-directory: .
id: generate-matrix
run: |
SUBDIRS=$(find . -maxdepth 1 -type d -not -name '.*' -not -name 'internal' | sed 's|./||' | tr '\n' ' ')
JSON_MATRIX=$(echo "$SUBDIRS" | jq -R -c -s 'split(" ")')
echo "::set-output name=matrix::$JSON_MATRIX"
shell: bash

gosec-scan:
runs-on: ubuntu-latest
needs: set-matrix
strategy:
matrix:
directory: ${{fromJson(needs.set-matrix.outputs.matrix)}}
env:
GO111MODULE: on
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'oldstable'
check-latest: true
cache: false
- name: Install Gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Run Gosec for ${{ matrix.directory }}
working-directory: ./${{ matrix.directory }}
run: gosec -exclude-dir=internal ./...
64 changes: 22 additions & 42 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,28 @@ on:
- ".github/dependabot.yml"

jobs:
set-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Generate Matrix
working-directory: .
id: generate-matrix
run: |
SUBDIRS=$(find . -maxdepth 1 -type d -not -name '.*' -not -name 'internal' | sed 's|./||' | tr '\n' ' ')
JSON_MATRIX=$(echo "$SUBDIRS" | jq -R -c -s 'split(" ")')
echo "::set-output name=matrix::$JSON_MATRIX"
shell: bash

govulncheck-check:
runs-on: ubuntu-latest
needs: set-matrix
strategy:
matrix:
directory: ${{fromJson(needs.set-matrix.outputs.matrix)}}
env:
GO111MODULE: on
steps:
Expand All @@ -35,46 +55,6 @@ jobs:
cache: false
- name: Install Govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Run govulncheck (paseto)
working-directory: ./paseto
run: govulncheck ./...
# -----
- name: Run govulncheck (fiberzap)
working-directory: ./fiberzap
run: govulncheck ./...
# -----
- name: Run govulncheck (otelfiber)
working-directory: ./otelfiber
run: govulncheck ./...
- name: Run govulncheck (swagger)
working-directory: ./swagger
run: govulncheck ./...
# -----
- name: Run govulncheck (casbin)
working-directory: ./casbin
run: govulncheck ./...
# -----
- name: Run govulncheck (fibernewrelic)
working-directory: ./fibernewrelic
run: govulncheck ./...
# -----
- name: Run govulncheck (opafiber)
working-directory: ./opafiber
run: govulncheck ./...
# -----
- name: Run govulncheck (fiberi18n)
working-directory: ./fiberi18n
run: govulncheck ./...
# -----
- name: Run govulncheck (fiberzerolog)
working-directory: ./fiberzerolog
run: govulncheck ./...
# -----
- name: Run govulncheck (jwt)
working-directory: ./jwt
run: govulncheck ./...
# -----
- name: Run govulncheck (websocket)
working-directory: ./websocket
- name: Run Govulncheck for ${{ matrix.directory }}
working-directory: ./${{ matrix.directory }}
run: govulncheck ./...
# -----

0 comments on commit ea00cb3

Please sign in to comment.