v2 - Removing redundant dependency injection code #6524
Workflow file for this run
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
name: Build and test | |
on: | |
merge_group: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: # Handy for testing | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
quesma-test-and-compile: | |
strategy: | |
matrix: | |
module: [ "quesma" ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Tune GitHub-hosted runner network | |
uses: smorimoto/tune-github-hosted-runner-network@v1 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
cache-dependency-path: ${{ matrix.module }}/go.sum | |
go-version: '1.23' | |
- name: gofmt | |
working-directory: ${{ matrix.module }} | |
run: gofmt -l -d . | (! grep . -q) || (gofmt -l -d .;exit 1) | |
- name: License Header Verification | |
working-directory: ${{ matrix.module }} | |
run: | | |
LICENSE_COMMENT="// Copyright Quesma, licensed under the Elastic License 2.0. | |
// SPDX-License-Identifier: Elastic-2.0" | |
failed=false | |
while IFS= read -r -d '' file; do | |
file_content=$(< "$file") | |
if [[ "$file_content" != "$LICENSE_COMMENT"* ]]; then | |
echo "License header missing or incorrect in file: $file" | |
failed=true | |
fi | |
done < <(find . -type f -name "*.go" -print0) | |
if [ "$failed" = true ]; then | |
exit 1 | |
fi | |
- name: Go Vet | |
working-directory: ${{ matrix.module }} | |
run: go vet ./... | |
- uses: dominikh/[email protected] | |
with: | |
version: "2024.1.1" | |
install-go: false | |
working-directory: ${{ matrix.module }} | |
- name: Build | |
working-directory: ${{ matrix.module }} | |
run: go build -v ./... | |
- name: Test (without race detection) | |
working-directory: ${{ matrix.module }} | |
run: go run gotest.tools/gotestsum@latest --format pkgname-and-test-fails ./... | |
build-quesma-docker-image: | |
uses: ./.github/workflows/build-quesma-docker-image.yml | |
build-log-generator: | |
strategy: | |
matrix: | |
module: [ "log-generator" ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
cache-dependency-path: ${{ matrix.module }}/go.sum | |
go-version: '1.23' | |
- name: Build and export | |
uses: docker/build-push-action@v6 | |
with: | |
context: ci/${{ matrix.module }}/. | |
tags: ${{ matrix.module }}:latest | |
outputs: type=docker,dest=/tmp/image.tar | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
env: | |
DOCKER_BUILD_SUMMARY: false | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.module }} | |
path: /tmp/image.tar | |
retention-days: 1 | |
smoke-test: | |
runs-on: ubuntu-latest | |
needs: [build-log-generator, build-quesma-docker-image] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
cache-dependency-path: smoke-test/go.sum | |
go-version: '1.23' | |
- name: Download images | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/images | |
- name: Load images | |
run: | | |
for file in /tmp/images/*/*.tar; do | |
docker load --input $file | |
done | |
docker image ls -a | |
- name: Build and start docker compose | |
timeout-minutes: 10 | |
run: docker compose -f ci/ci.yml up -d | |
- name: Wait until services are healthy | |
timeout-minutes: 6 | |
working-directory: smoke-test | |
run: go run . --wait-for-start | |
- name: Verify if data is flowing | |
working-directory: smoke-test | |
env: | |
GITHUB_ACTIONS: true | |
run: go run . | |
- name: Print docker status | |
if: failure() | |
run: docker compose -f ci/ci.yml ps | |
- name: Print docker compose logs | |
if: failure() | |
run: docker compose -f ci/ci.yml logs |