Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix-dates-2
Browse files Browse the repository at this point in the history
  • Loading branch information
jakozaur committed Oct 13, 2024
2 parents 38d99a4 + 0b117b5 commit 6fdebc5
Show file tree
Hide file tree
Showing 84 changed files with 3,909 additions and 817 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/build-quesma-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Reusable workflow that builds Quesma Docker image and either:
# - pushes it to Docker Hub
# - or exports it to .tar artifact

name: Docker image build
on:
workflow_call: # Can be reused from another workflow
inputs:
VERSION:
description: 'Version number to tag the image with (optional)'
default: nightly
required: false
type: string
PUSH:
description: 'Whether to push the image to the registry (optional)' # if not, we will export it to .tar artifact
default: false
required: false
type: boolean
REF:
description: 'The branch, tag or SHA to checkout. By default it will use the default branch'
default: ''
required: false
type: string
secrets:
DOCKER_USER:
required: false
DOCKER_PAT:
required: false

jobs:
build-quesma-docker-image:
strategy:
matrix:
module: [ "quesma" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.REF }}

- 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: Log in to Docker Hub
uses: docker/login-action@v3
if: ${{ inputs.PUSH }}
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PAT }}

- name: Set the build date
run: echo QUESMA_BUILD_DATE=$(git --no-pager log -1 --date=format:'%Y-%m-%d' --format="%ad") >> $GITHUB_ENV

# If we don't push the image, we build it only for the host architecture and export it to .tar file
# This step is similar to "Build and push", but avoids building arm64 image, which takes
# a lot of time on GitHub Actions.
- name: Build and export
uses: docker/build-push-action@v6
if: ${{ !inputs.PUSH }}
with:
context: ${{ matrix.module }}/.
tags: |
quesma/quesma:${{ inputs.VERSION }}
quesma/quesma:nightly
push: false
outputs: type=docker,dest=/tmp/image.tar
cache-from: type=gha
cache-to: type=gha,mode=max
env:
DOCKER_BUILD_SUMMARY: false

# If we push the image, we build it for both amd64 and arm64 and don't export it
- name: Build and push
uses: docker/build-push-action@v6
if: ${{ inputs.PUSH }}
with:
context: ${{ matrix.module }}/.
tags: |
quesma/quesma:${{ inputs.VERSION }}
quesma/quesma:nightly
push: true
build-args: |
QUESMA_BUILD_SHA=${{ github.sha }}
QUESMA_VERSION=${{ inputs.VERSION }}
QUESMA_BUILD_DATE=${{ env.QUESMA_BUILD_DATE }}
platforms: linux/amd64,linux/arm64
env:
DOCKER_BUILD_SUMMARY: false

- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ !inputs.PUSH }}
with:
name: ${{ matrix.module }}
path: /tmp/image.tar
retention-days: 1
65 changes: 0 additions & 65 deletions .github/workflows/docker-image-latest.yml

This file was deleted.

39 changes: 2 additions & 37 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,8 @@ on: # @TODO should we run it on PRs?
description: 'Commit hash to run the tests'
required: true
jobs:

build-quesma-docker-image:
strategy:
matrix:
module: [ "quesma" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: ## @TODO REMOVE
ref: ${{ github.event.inputs.GIT_REF }}

- 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.22'

- name: Build and export
uses: docker/build-push-action@v6
with:
context: ${{ 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
uses: ./.github/workflows/build-quesma-docker-image.yml

e2e-test-run:
runs-on: ubuntu-latest
Expand All @@ -60,7 +25,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: smoke-test/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Download images
uses: actions/download-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-notice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version: '1.22'
go-version: '1.23'

- name: Install go-licence-detector
working-directory: ${{ matrix.module }}
Expand Down
57 changes: 46 additions & 11 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Integration tests

on:
# #merge_group:
# push:
# branches: [ "main" ]
push:
branches: [ "main" ]
workflow_dispatch:
inputs:
GIT_REF:
description: 'Commit hash to run the tests'
required: true
jobs:
build-quesma-docker-image:
uses: ./.github/workflows/build-quesma-docker-image.yml
with:
REF: ${{inputs.GIT_REF}}

integration-test-run:
runs-on: ubuntu-latest
needs: [build-quesma-docker-image]
steps:
- uses: actions/checkout@v4
with: ## @TODO REMOVE
Expand All @@ -22,20 +26,51 @@ jobs:
uses: actions/setup-go@v5
with:
cache-dependency-path: smoke-test/go.sum
go-version: '1.22'
go-version: '1.23'

# (perhaps prefetching these should be considered)
# - name: Download images
# uses: actions/download-artifact@v4
# with:
# path: /tmp/images
- 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: Set environment variable
run: echo "EXECUTING_ON_GITHUB_CI=true" >> $GITHUB_ENV

- name: Get last commit author
id: get_author
run: echo "::set-output name=author::$(git log -1 --pretty=format:'%an <%ae> sha1={%H}')"

- name: Run integration tests
working-directory: ci/it
# env:
# EXECUTING_ON_GITHUB_CI: true
run: go test -v

- name: Send Slack notification on failure
if: failure()
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: |
:exclamation: *Integration tests failed.* :exclamation: @channel
Last commit by: ${{ steps.get_author.outputs.author }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Send Slack notification on success
if: success()
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: |
:white_check_mark: *Integration tests passed.* Good job team!
Last commit by: ${{ steps.get_author.outputs.author }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}


31 changes: 31 additions & 0 deletions .github/workflows/nightly-docker-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Docker image build (nightly)
# Pipeline which builds `nightly` Docker images for Quesma
# pushes them to Docker Hub as `quesma/quesma:nightly` (and `quesma/quesma:<VERSION>`, if VERSION is specified explicitly)
#
# This workflow is triggered by a push/merge to the `main` branch
# quesma/quesma:nightly image is a pointer to latest released version.
#
# This workflow is not reusable, use build-quesma-docker-image.yml as a reusable workflow.
on:
push:
branches: [ "main" ]
workflow_dispatch: # Handy for testing
inputs:
VERSION:
description: 'Version number to tag the image with (optional)'
default: nightly
required: true
PUSH:
description: 'Whether to push the image to the registry'
default: false
required: true
jobs:
build-quesma-docker-image:
uses: ./.github/workflows/build-quesma-docker-image.yml
with:
VERSION: ${{ inputs.VERSION || 'nightly' }} # when called from the main branch, `github.event.inputs.VERSION` doesn't use default value and is just empty
# Pushes to DockerHub only for `main` branch builds, unless set explicitly in the job input
PUSH: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || inputs.PUSH }}
secrets:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PAT: ${{ secrets.DOCKER_PAT }}
Loading

0 comments on commit 6fdebc5

Please sign in to comment.