Port CI to Forgejo Actions
All checks were successful
All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
df07972db6
commit
2a4be9acf4
4 changed files with 67 additions and 99 deletions
63
.forgejo/workflows/ci.yml
Normal file
63
.forgejo/workflows/ci.yml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['**']
|
||||
tags: ['**']
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
GOPROXY: https://goproxy.jonasled.dev,direct
|
||||
|
||||
jobs:
|
||||
backend-test:
|
||||
runs-on: default
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v7
|
||||
- uses: https://code.forgejo.org/actions/setup-go@v7
|
||||
with:
|
||||
go-version: '1.27'
|
||||
- run: |
|
||||
go install github.com/swaggo/swag/cmd/swag@latest
|
||||
cd backend
|
||||
"$(go env GOPATH)/bin/swag" init -g main.go --output docs
|
||||
go test ./... -v -coverprofile=coverage.out
|
||||
go tool cover -func=coverage.out
|
||||
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
||||
with:
|
||||
name: coverage
|
||||
path: backend/coverage.out
|
||||
retention-days: 7
|
||||
|
||||
frontend-docker:
|
||||
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
|
||||
with:
|
||||
image-suffix: /frontend
|
||||
context-dir: frontend
|
||||
secrets: inherit
|
||||
|
||||
backend-docker:
|
||||
needs: [backend-test]
|
||||
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
|
||||
with:
|
||||
image-suffix: /backend
|
||||
context-dir: backend
|
||||
secrets: inherit
|
||||
|
||||
chart:
|
||||
# helm install mailbox oci://forgejo.jonasled.dev/jonasled/disposable-mailbox/charts/disposable-mailbox --version <version>
|
||||
needs: [frontend-docker, backend-docker]
|
||||
if: github.ref_type == 'tag' || github.ref_name == github.event.repository.default_branch
|
||||
uses: infra/ci-snippets/.forgejo/workflows/helm-build.yml@master
|
||||
with:
|
||||
chart-path: helm/disposable-mailbox
|
||||
push: true
|
||||
version-from-run-number: true
|
||||
version-offset: '549'
|
||||
pre-package: |
|
||||
f=helm/disposable-mailbox/values.yaml
|
||||
sed -i '/repository: .*disposable-mailbox\/backend/,/tag:/ s|tag: .*|tag: "latest@${{ needs.backend-docker.outputs.digest }}"|' $f
|
||||
sed -i '/repository: .*disposable-mailbox\/frontend/,/tag:/ s|tag: .*|tag: "latest@${{ needs.frontend-docker.outputs.digest }}"|' $f
|
||||
grep -n 'tag: "latest@sha256:' $f
|
||||
test "$(grep -c 'tag: "latest@sha256:' $f)" = 2
|
||||
secrets: inherit
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
stages:
|
||||
- test
|
||||
- build
|
||||
- bundle
|
||||
|
||||
BackendTest:
|
||||
stage: test
|
||||
image: golang:1.27-alpine
|
||||
needs: []
|
||||
before_script:
|
||||
- export GOPROXY=https://goproxy.jonasled.dev,direct
|
||||
- go install github.com/swaggo/swag/cmd/swag@latest
|
||||
- go install github.com/t-yuki/gocover-cobertura@latest
|
||||
script:
|
||||
- export GOPROXY=https://goproxy.jonasled.dev,direct
|
||||
- cd backend
|
||||
- swag init -g main.go --output docs
|
||||
- go test ./... -v -coverprofile=coverage.out
|
||||
- go tool cover -func=coverage.out
|
||||
- gocover-cobertura < coverage.out > coverage.xml
|
||||
coverage: '/total:\s+\(statements\)\s+(\d+\.\d+)%/'
|
||||
artifacts:
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: backend/coverage.xml
|
||||
paths:
|
||||
- backend/coverage.out
|
||||
expire_in: 1 week
|
||||
|
||||
.docker-build: &docker-build
|
||||
image: jonasled.dev/infra/docker-build:master@sha256:d6f535fcb2817edec221eac33331369863f3409322d5f2d516356e7e7554326b
|
||||
stage: build
|
||||
needs: []
|
||||
|
||||
FrontendDocker:
|
||||
<<: *docker-build
|
||||
script:
|
||||
- cd frontend
|
||||
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/frontend
|
||||
- build-image
|
||||
- mv image-hash.txt $CI_PROJECT_DIR/image-hash-frontend.txt
|
||||
- mv image-scan-report.bom.json $CI_PROJECT_DIR/frontend.bom.json
|
||||
artifacts:
|
||||
paths:
|
||||
- image-hash-frontend.txt
|
||||
- frontend.bom.json
|
||||
|
||||
BackendDocker:
|
||||
<<: *docker-build
|
||||
needs:
|
||||
- BackendTest
|
||||
script:
|
||||
- cd backend
|
||||
- export IMAGE_NAME=$CI_REGISTRY_IMAGE/backend
|
||||
- build-image
|
||||
- mv image-hash.txt $CI_PROJECT_DIR/image-hash-backend.txt
|
||||
- mv image-scan-report.bom.json $CI_PROJECT_DIR/backend.bom.json
|
||||
artifacts:
|
||||
paths:
|
||||
- image-hash-backend.txt
|
||||
- backend.bom.json
|
||||
|
||||
HelmChart:
|
||||
# helm install mailbox oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts/disposable-mailbox --version <version>
|
||||
image:
|
||||
name: alpine/helm:4.3.2
|
||||
entrypoint: [""]
|
||||
stage: bundle
|
||||
needs:
|
||||
- FrontendDocker
|
||||
- BackendDocker
|
||||
variables:
|
||||
CHART_DIR: helm/disposable-mailbox
|
||||
CHART_REPO: oci://$CI_REGISTRY/$CI_PROJECT_PATH/charts
|
||||
before_script:
|
||||
- apk add --no-cache yq
|
||||
script:
|
||||
- BACKEND_TAG=$(cat image-hash-backend.txt)
|
||||
- FRONTEND_TAG=$(cat image-hash-frontend.txt)
|
||||
- yq e -i ".backend.image.tag = \"latest@${BACKEND_TAG}\"" "$CHART_DIR/values.yaml"
|
||||
- yq e -i ".frontend.image.tag = \"latest@${FRONTEND_TAG}\"" "$CHART_DIR/values.yaml"
|
||||
- helm lint "$CHART_DIR"
|
||||
- |
|
||||
# Versions must only grow: major.minor from Chart.yaml, patch = pipeline IID.
|
||||
BASE_VERSION=$(sed -n 's/^version: *//p' "$CHART_DIR/Chart.yaml" | cut -d. -f1,2)
|
||||
helm package "$CHART_DIR" --version "${BASE_VERSION}.${CI_PIPELINE_IID}" --destination dist
|
||||
- helm registry login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
|
||||
- helm push dist/disposable-mailbox-*.tgz "$CHART_REPO"
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
artifacts:
|
||||
paths:
|
||||
- dist/
|
||||
|
|
@ -8,6 +8,6 @@ keywords:
|
|||
- email
|
||||
- disposable
|
||||
- mailbox
|
||||
home: https://jonasled.dev/jonasled/disposable-mailbox
|
||||
home: https://forgejo.jonasled.dev/jonasled/disposable-mailbox
|
||||
sources:
|
||||
- https://jonasled.dev/jonasled/disposable-mailbox
|
||||
- https://forgejo.jonasled.dev/jonasled/disposable-mailbox
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ backend:
|
|||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: jonasled.dev/jonasled/disposable-mailbox/backend
|
||||
repository: forgejo.jonasled.dev/jonasled/disposable-mailbox/backend
|
||||
pullPolicy: IfNotPresent
|
||||
# Defaults to chart appVersion
|
||||
tag: ""
|
||||
|
|
@ -129,7 +129,7 @@ frontend:
|
|||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: jonasled.dev/jonasled/disposable-mailbox/frontend
|
||||
repository: forgejo.jonasled.dev/jonasled/disposable-mailbox/frontend
|
||||
pullPolicy: IfNotPresent
|
||||
tag: ""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue