Skip to content

Commit

Permalink
ci/cd: sync configuration with the go service template
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Dec 28, 2023
1 parent 139324c commit 07077ca
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 27 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/cd.docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
schedule:
- cron: 0 7 1 * * # at 07:00 on day-of-month 1, UTC

workflow_call:

workflow_dispatch:
inputs:
reason:
Expand All @@ -19,7 +21,7 @@ on:
required: true

concurrency:
group: pages
group: docs
cancel-in-progress: true

jobs:
Expand All @@ -34,17 +36,25 @@ jobs:
- name: Set up Node.js environment
uses: actions/[email protected]
with:
node-version: 18
node-version: 20
cache: npm
cache-dependency-path: docs/package-lock.json
check-latest: true
- name: Install dependencies
run: ./Taskfile docs npm ci
- name: Set up GitHub Pages
uses: actions/[email protected]
- name: Install dependencies
run: ./Taskfile docs npm ci

- name: Build static HTML with Next.js
run: ./Taskfile docs publish
- name: Build the documentation
run: |
path=$(
gh api repos/${{ github.repository }}/pages \
--jq '.html_url' |
awk -F'https?://[^/]+' '{print $2}'
)
TARGET=static BASE_PATH="${path%/}" ./Taskfile docs build
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload the documentation
uses: actions/[email protected]
with: { path: docs/dist }
Expand All @@ -57,7 +67,6 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
id-token: write
pages: write

Expand Down
43 changes: 27 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
- 'go.{mod,sum}'
- 'Makefile'
- 'Taskfile'
tags: [ '!*' ]
tags: [ 'v*' ]

schedule:
- cron: 0 7 1 * * # at 07:00 on day-of-month 1, UTC
Expand All @@ -46,15 +46,10 @@ jobs:
uses: actions/[email protected]
with:
go-version: 1.21.x
cache-dependency-path: tools/go.sum
check-latest: true
- name: Set up environment
run: make tools

- name: Run linter
run: make lint
- name: Run fast check the state
run: make fast-check
uses: golangci/[email protected]

test:
name: Testing
Expand All @@ -74,7 +69,9 @@ jobs:
with: { fetch-depth: 0 }
- name: Set up Go environment
uses: actions/[email protected]
with: { go-version: '${{ matrix.go }}', check-latest: true }
with:
go-version: '${{ matrix.go }}'
check-latest: true
- name: Set up environment
run: make env deps

Expand All @@ -88,36 +85,50 @@ jobs:
if: matrix.go == '1.21.x'
- name: Store code coverage report
uses: actions/[email protected]
if: matrix.go == '1.21.x'
with: { name: code-coverage-report, path: c.out }
if: matrix.go == '1.21.x'

- name: Check installation
run: |
make install
[ $(ls bin/linux/*/* | wc -l) = 1 ]
publish:
name: Documentation
needs: [ test ]
uses: ./.github/workflows/cd.docs.yml
permissions:
id-token: write
pages: write
if: true

release:
name: Distribution
needs: [ test ]
uses: ./.github/workflows/cd.dist.yml
secrets:
GORELEASER_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
if: startsWith(github.ref, 'refs/tags/v')

report:
name: Reporting
needs: [ test ]
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/[email protected]
with: { fetch-depth: 0 }

- name: Fetch code coverage report
uses: actions/[email protected]
with: { name: code-coverage-report }
- name: Send code coverage report to Codecov (codecov.io)
- name: Send code coverage report to Codecov
uses: codecov/[email protected]
with: { files: c.out }

notify:
name: Notifying
needs: [ lint, test ]
needs: [ lint, report ]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' && (failure() || success())
if: github.event_name != 'pull_request'
&& (failure() || success())

steps:
- name: Checkout the repository
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/cleanup.caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
schedule:
- cron: 0 6 1 * * # at 06:00 on day-of-month 1, UTC

workflow_call:

workflow_dispatch:
inputs:
reason:
Expand All @@ -16,7 +18,8 @@ jobs:
delete:
name: Deleting
runs-on: ubuntu-latest

permissions:
actions: write
env:
GITHUB_TOKEN: ${{ github.token }}

Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/cleanup.runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
schedule:
- cron: 0 6 1 * * # at 06:00 on day-of-month 1, UTC

workflow_call:

workflow_dispatch:
inputs:
pattern:
Expand Down Expand Up @@ -35,18 +37,25 @@ jobs:
delete:
name: Deleting
runs-on: ubuntu-latest
permissions:
actions: write

steps:
- name: Delete workflow runs
uses: Mattraks/[email protected]
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
delete_workflow_pattern: ${{ github.event.inputs.pattern || 'all' }}
delete_workflow_pattern: >-
${{
github.event.inputs.pattern != 'All'
&& github.event.inputs.pattern
|| ''
}}
dry_run: ${{ fromJSON('["", "true"]')[github.event.inputs.dry_run == 'true'] }}
retain_days: 0
keep_minimum_runs: 0
- name: Cleanup workflow runs
- name: Finishing workflow runs deletion
run: |
gh run list \
-R '${{ github.repository }}' \
Expand All @@ -55,9 +64,9 @@ jobs:
--json databaseId \
--jq '.[] | .databaseId' |
xargs -n1 --no-run-if-empty gh run delete -R '${{ github.repository }}'
if: github.event.inputs.pattern == 'All'
env:
GITHUB_TOKEN: ${{ github.token }}
if: github.event.inputs.pattern == 'All'

notify:
name: Notifying
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cleanup.stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
schedule:
- cron: 0 6 * * * # at 06:00 every day, UTC

workflow_call:

workflow_dispatch:
inputs:
reason:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/warmup.caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ jobs:
- name: Install dependencies
run: make env deps

docs:
name: Caching docs deps
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/[email protected]
with: { fetch-depth: 0 }
- name: Set up Node.js environment
uses: actions/[email protected]
with:
node-version: 20
cache: npm
cache-dependency-path: docs/package-lock.json
check-latest: true
- name: Install dependencies
run: ./Taskfile docs npm ci

tools:
name: Caching tools
runs-on: ubuntu-latest
Expand Down

0 comments on commit 07077ca

Please sign in to comment.