chore(deps): update all non-major dependencies (#297) #1260
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2023 Siemens AG | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# | |
# Author: Michael Adler <[email protected]> | |
--- | |
name: CI | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
container: golang:1.24.0@sha256:3f7444391c51a11a039bf0359ee81cc64e663c17d787ad0e637a4de1a3f62a71 | |
strategy: | |
matrix: | |
# even though Windows is not officially supported, we want it to at least compile successfully | |
goos: [linux, windows] | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup Golang caches | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-golang- | |
- name: Disable git security features | |
run: git config --global safe.directory '*' | |
- run: .ci/setup-build.sh | |
- name: build for ${{ matrix.goos }} | |
run: just build | |
env: | |
GOOS: ${{ matrix.goos }} | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
container: golang:1.24.0@sha256:3f7444391c51a11a039bf0359ee81cc64e663c17d787ad0e637a4de1a3f62a71 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup Golang caches | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-golang- | |
- run: go test -race -coverprofile=coverage.out -covermode=atomic -timeout 30s --tags=testing ./... | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.out | |
test-postgres: | |
runs-on: ubuntu-latest | |
name: Test PostgreSQL | |
container: golang:1.24.0@sha256:3f7444391c51a11a039bf0359ee81cc64e663c17d787ad0e637a4de1a3f62a71 | |
services: | |
postgres: | |
image: postgres:17@sha256:81f32a88ec561664634637dd446487efd5f9d90996304b96210078e90e5c8b21 | |
env: | |
# see https://hub.docker.com/_/postgres | |
POSTGRES_HOST: postgres | |
POSTGRES_PORT: 5432 | |
POSTGRES_DB: wfx | |
POSTGRES_USER: wfx | |
POSTGRES_PASSWORD: secret | |
POSTGRES_HOST_AUTH_METHOD: trust | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 3s | |
--health-timeout 5s | |
--health-retries 20 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup Golang caches | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-golang- | |
- run: .ci/setup-postgres.sh | |
- run: just postgres-integration-test | |
env: | |
PGHOST: postgres | |
PGPORT: 5432 | |
PGDATABASE: wfx | |
PGUSER: wfx | |
PGPASSWORD: secret | |
PGSSLMODE: disable | |
- name: Upload coverage to Codecov | |
# note: v4 is buggy and fails to upload this report | |
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.out | |
test-mysql: | |
runs-on: ubuntu-latest | |
name: Test MySQL | |
container: golang:1.24.0@sha256:3f7444391c51a11a039bf0359ee81cc64e663c17d787ad0e637a4de1a3f62a71 | |
services: | |
mysql: | |
image: mysql:8-debian@sha256:49f4fcb0087318aa1c222c7e8ceacbb541cdc457c6307d45e6ee4313f4902e33 | |
env: | |
# see https://hub.docker.com/_/mysql | |
MYSQL_DATABASE: wfx | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_USER: wfx | |
MYSQL_PASSWORD: secret | |
MYSQL_HOST: mysql | |
# Set health checks to wait until mysql has started | |
options: >- | |
--health-cmd="mysqladmin ping --silent" | |
--health-interval 3s | |
--health-timeout 5s | |
--health-retries 20 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Setup Golang caches | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-golang- | |
- run: .ci/setup-mysql.sh | |
- run: just mysql-integration-test | |
env: | |
MYSQL_DATABASE: wfx | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_USER: wfx | |
MYSQL_PASSWORD: secret | |
MYSQL_HOST: mysql | |
- name: Upload coverage to Codecov | |
# note: v4 is buggy and fails to upload this report | |
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.out | |
cli-tests: | |
name: CLI Tests | |
runs-on: ubuntu-latest | |
container: golang:1.24.0@sha256:3f7444391c51a11a039bf0359ee81cc64e663c17d787ad0e637a4de1a3f62a71 | |
services: | |
mysql: | |
image: mysql:8-debian@sha256:49f4fcb0087318aa1c222c7e8ceacbb541cdc457c6307d45e6ee4313f4902e33 | |
env: | |
# see https://hub.docker.com/_/mysql | |
MYSQL_DATABASE: wfx | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_USER: wfx | |
MYSQL_PASSWORD: secret | |
MYSQL_HOST: mysql | |
# Set health checks to wait until mysql has started | |
options: >- | |
--health-cmd="mysqladmin ping --silent" | |
--health-interval 3s | |
--health-timeout 5s | |
--health-retries 20 | |
postgres: | |
image: postgres:17@sha256:81f32a88ec561664634637dd446487efd5f9d90996304b96210078e90e5c8b21 | |
env: | |
# see https://hub.docker.com/_/postgres | |
POSTGRES_HOST: postgres | |
POSTGRES_PORT: 5432 | |
POSTGRES_DB: wfx | |
POSTGRES_USER: wfx | |
POSTGRES_PASSWORD: secret | |
POSTGRES_HOST_AUTH_METHOD: trust | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 3s | |
--health-timeout 5s | |
--health-retries 20 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
submodules: "true" | |
- name: Setup Golang caches | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-golang- | |
- run: .ci/setup-cli-tests.sh | |
- name: Disable git security features | |
run: git config --global safe.directory '*' | |
- name: install wfx | |
run: go install . | |
- name: install wfxctl | |
run: go install ./cmd/wfxctl | |
- name: build plugins | |
run: go build -C example/plugin | |
- name: run tests | |
env: | |
PGHOST: postgres | |
PGPORT: 5432 | |
PGUSER: wfx | |
PGPASSWORD: secret | |
PGDATABASE: wfx | |
MYSQL_DATABASE: wfx | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_USER: wfx | |
MYSQL_PASSWORD: secret | |
MYSQL_HOST: mysql | |
working-directory: test | |
run: export PATH=$(go env GOPATH)/bin:$PATH; bats . | |
lint: | |
runs-on: ubuntu-latest | |
name: Lint | |
container: golang:1.24.0@sha256:3f7444391c51a11a039bf0359ee81cc64e663c17d787ad0e637a4de1a3f62a71 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Disable git security features | |
run: git config --global safe.directory '*' | |
- run: .ci/setup-lint.sh | |
- run: just lint | |
reuse: | |
runs-on: ubuntu-latest | |
name: Reuse | |
container: fsfe/reuse:5.0.2@sha256:000c3fc0c3e39e95b36fa9966d0104ae0496571b7de7b9f0c889a66438581bda | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- run: reuse lint || true # just a warning | |
generate: | |
name: Generate Code | |
runs-on: ubuntu-latest | |
container: golang:1.24.0@sha256:3f7444391c51a11a039bf0359ee81cc64e663c17d787ad0e637a4de1a3f62a71 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Install packages | |
run: .ci/setup-generate.sh | |
- name: Disable git security features | |
run: git config --global safe.directory '*' | |
- run: just generate | |
- run: git diff --exit-code | |
openapi-check-breaking: | |
name: API check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Check for breaking changes in API | |
id: breaking_changes | |
uses: oasdiff/oasdiff-action/[email protected] | |
with: | |
base: https://raw.githubusercontent.com/siemens/wfx/refs/heads/main/spec/wfx.openapiv3.yml | |
revision: spec/wfx.openapiv3.yml | |
fail-on: ERR | |
release: | |
name: Release | |
if: startsWith(github.event.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
attestations: write | |
id-token: write | |
needs: | |
- build | |
- test | |
- test-postgres | |
- test-mysql | |
- cli-tests | |
- lint | |
- reuse | |
- generate | |
- openapi-check-breaking | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Export Golang version as env variable | |
run: | | |
GO_VERSION=$(sed -n 's/.*container: golang:\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' .github/workflows/ci.yml | head -n1) | |
# You can make an environment variable available to any subsequent | |
# steps in a workflow job by defining or updating the environment | |
# variable and writing this to the GITHUB_ENV environment file. | |
echo "GO_VERSION=$GO_VERSION" | tee -a "$GITHUB_ENV" | |
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5 | |
with: | |
go-version: "${{ env.GO_VERSION }}" | |
- name: Setup build | |
run: sudo .ci/setup-build.sh | |
- name: Run GoReleaser | |
run: export CC="$(pwd)/.ci/zcc"; goreleaser release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |