test: add integration tests

This commit is contained in:
Julien Neuhart
2025-03-21 11:18:20 +01:00
parent 820b914291
commit 0febb60a3f
139 changed files with 7561 additions and 16381 deletions

View File

@@ -1,5 +1,5 @@
name: Build and Push
description: Build and push Docker images
name: Build Test Push
description: Build, test and push Docker images for a given platform
author: Julien Neuhart
inputs:
@@ -19,6 +19,9 @@ inputs:
version:
description: Gotenberg version
required: true
skip_integrations_tests:
description: Define whether to skip integration testing
default: false
alternate_repository:
description: Alternate repository to push the tags to
dry_run:
@@ -27,10 +30,10 @@ inputs:
outputs:
tags:
description: Comma separated list of tag
value: ${{ steps.build_push.outputs.tags }}
value: ${{ steps.build.outputs.tags }}
tags_cloud_run:
description: Comma separated list of Cloud Run tags (linux/amd64 only)
value: ${{ steps.build_push.outputs.tags_cloud_run }}
value: ${{ steps.build.outputs.tags_cloud_run }}
runs:
using: composite
@@ -50,18 +53,35 @@ runs:
username: ${{ inputs.docker_hub_username }}
password: ${{ inputs.docker_hub_password }}
- name: Build and push ${{ inputs.platform }}
id: build_push
- name: Build ${{ inputs.platform }}
id: build
shell: bash
run: |
.github/actions/build-push/build-push.sh \
.github/actions/build-test-push/build.sh \
--version "${{ inputs.version }}" \
--platform "${{ inputs.platform }}" \
--alternate-repository "${{ inputs.alternate_repository }}" \
--dry-run "${{ inputs.dry_run }}"
- name: Run integration tests
if: ${{ inputs.skip_integrations_tests != 'true' }}
shell: bash
run: |
.github/actions/build-test-push/test.sh \
--version "${{ inputs.version }}" \
--platform "${{ inputs.platform }}" \
--alternate-repository "${{ inputs.alternate_repository }}" \
--dry-run "${{ inputs.dry_run }}"
- name: Push
shell: bash
run: |
.github/actions/build-test-push/push.sh \
--tags "${{ steps.build.outputs.tags }}" \
--dry-run "${{ inputs.dry_run }}"
- name: Outputs
shell: bash
run: |
echo "tags=${{ steps.build_push.outputs.tags }}"
echo "tags_cloud_run=${{ steps.build_push.outputs.tags_cloud_run }}"
echo "tags=${{ steps.build.outputs.tags }}"
echo "tags_cloud_run=${{ steps.build.outputs.tags_cloud_run }}"

View File

@@ -92,7 +92,7 @@ fi
tags_flags=()
tags_cloud_run_flags=()
echo "Will push the following tags:"
echo "Will use the following tags:"
for tag in "${tags[@]}"; do
tags_flags+=("-t" "$tag")
echo "- $tag"
@@ -103,7 +103,7 @@ for tag in "${tags_cloud_run[@]}"; do
done
echo
# Build and push images.
# Build images.
run_cmd() {
local cmd="$1"
@@ -126,6 +126,8 @@ join() {
echo "$*"
}
no_arch_tag="$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$version"
cmd="docker buildx build \
--build-arg GOLANG_VERSION=$GOLANG_VERSION \
--build-arg GOTENBERG_VERSION=$version \
@@ -134,9 +136,10 @@ cmd="docker buildx build \
--build-arg NOTO_COLOR_EMOJI_VERSION=$NOTO_COLOR_EMOJI_VERSION \
--build-arg PDFTK_VERSION=$PDFTK_VERSION \
--build-arg PDFCPU_VERSION=$PDFCPU_VERSION \
--push \
--platform $platform \
--load \
${tags_flags[*]} \
-t $no_arch_tag \
-f $DOCKERFILE $DOCKER_BUILD_CONTEXT
"
run_cmd "$cmd"
@@ -149,19 +152,10 @@ if [ "$platform" != "linux/amd64" ]; then
exit 0
fi
source_tag_cloud_run="$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$version-${arch[1]}"
cmd="docker pull $source_tag_cloud_run"
run_cmd "$cmd"
target_tag_cloud_run="$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$version"
cmd="docker image tag $source_tag_cloud_run $target_tag_cloud_run"
run_cmd "$cmd"
cmd="docker build \
--build-arg DOCKER_REGISTRY=$DOCKER_REGISTRY \
--build-arg DOCKER_REPOSITORY=$DOCKER_REPOSITORY \
--build-arg GOTENBERG_VERSION=$version \
--push \
${tags_cloud_run_flags[*]} \
-f $DOCKERFILE_CLOUDRUN $DOCKER_BUILD_CONTEXT
"

70
.github/actions/build-test-push/push.sh vendored Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
# Exit early.
# See: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin.
set -e
# Source dot env file.
source .env
# Arguments.
tags=""
dry_run=""
while [[ $# -gt 0 ]]; do
case $1 in
--tags)
tags="$2"
shift 2
;;
--dry-run)
dry_run=$2
shift 2
;;
*)
echo "Unknown option $1"
exit 1
;;
esac
done
echo "Push tag(s) 📦"
echo
echo "Tag(s) to push:"
IFS=',' read -ra tags_to_push <<< "$tags"
for tag in "${tags_to_push[@]}"; do
echo "- $tag"
done
if [ "$dry_run" = "true" ]; then
echo "🚧 Dry run"
fi
echo
# Push tags.
run_cmd() {
local cmd="$1"
if [ "$dry_run" = "true" ]; then
echo "🚧 Dry run - would run the following command:"
echo "$cmd"
echo
else
echo "⚙️ Running command:"
echo "$cmd"
eval "$cmd"
echo
fi
}
for tag in "${tags_to_push[@]}"; do
cmd="docker push $tag"
run_cmd "$cmd"
echo "➡️ $tag pushed"
echo
done
echo "✅ Done!"
exit 0

79
.github/actions/build-test-push/test.sh vendored Executable file
View File

@@ -0,0 +1,79 @@
#!/bin/bash
# Exit early.
# See: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin.
set -e
# Source dot env file.
source .env
# Arguments.
version=""
platform=""
alternate_repository=""
dry_run=""
while [[ $# -gt 0 ]]; do
case $1 in
--version)
version="${2//v/}"
shift 2
;;
--platform)
platform="$2"
shift 2
;;
--alternate-repository)
alternate_repository="$2"
shift 2
;;
--dry-run)
dry_run="$2"
shift 2
;;
*)
echo "Unknown option $1"
exit 1
;;
esac
done
echo "Integration testing 🧪"
echo
echo "Gotenberg version: $version"
echo "Target platform: $platform"
repository=$DOCKER_REPOSITORY
if [ -n "$alternate_repository" ]; then
echo "⚠️ Using $alternate_repository for DOCKER_REPOSITORY"
repository=$alternate_repository
fi
if [ "$dry_run" = "true" ]; then
echo "🚧 Dry run"
fi
echo
# Test image.
run_cmd() {
local cmd="$1"
if [ "$dry_run" = "true" ]; then
echo "🚧 Dry run - would run the following command:"
echo "$cmd"
echo
else
echo "⚙️ Running command:"
echo "$cmd"
eval "$cmd"
echo
fi
}
cmd="make test-integration DOCKER_REPOSITORY=$repository GOTENBERG_VERSION=$version PLATFORM=$platform"
run_cmd "$cmd"
echo "✅ Done!"
exit 0

View File

@@ -49,7 +49,6 @@ fi
if [ "$dry_run" = "true" ]; then
echo "🚧 Dry run"
fi
echo
# Build merge map.

View File

@@ -20,12 +20,13 @@ jobs:
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: ${{ github.event.release.tag_name }}
version: pr-${{ github.event.pull_request.number }}
platform: linux/amd64
skip_integrations_tests: true
release_386:
name: Release linux/386
@@ -39,12 +40,13 @@ jobs:
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: ${{ github.event.release.tag_name }}
version: pr-${{ github.event.pull_request.number }}
platform: linux/386
skip_integrations_tests: true
release_arm64:
name: Release linux/arm64
@@ -58,12 +60,13 @@ jobs:
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: ${{ github.event.release.tag_name }}
version: pr-${{ github.event.pull_request.number }}
platform: linux/arm64
skip_integrations_tests: true
release_arm_v7:
name: Release linux/arm/v7
@@ -77,12 +80,13 @@ jobs:
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: ${{ github.event.release.tag_name }}
version: pr-${{ github.event.pull_request.number }}
platform: linux/arm/v7
skip_integrations_tests: true
merge_clean_release_tags:
needs:

View File

@@ -17,66 +17,74 @@ permissions:
jobs:
lint:
name: Lint
name: Lint Golang codebase
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
cache: false
- name: Checkout source code
uses: actions/checkout@v4
go-version-file: go.mod
- name: Run linters
uses: golangci/golangci-lint-action@v6
with:
version: v1.64.2
tests:
needs:
- lint
name: Tests
lint-prettier:
name: Lint non-Golang codebase
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout source code
uses: actions/checkout@v4
- name: Build testing environment
run: make build build-tests
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
- name: Install Dependencies
run: npm i
- name: Run linters
run: make lint-prettier
test-unit:
needs:
- lint
- lint-prettier
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run tests
run: make tests-once
- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
run: make test-unit
snapshot_amd64:
if: github.event_name == 'pull_request'
needs:
- tests
- test-unit
name: Snapshot linux/amd64
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -87,19 +95,19 @@ jobs:
snapshot_386:
if: github.event_name == 'pull_request'
needs:
- tests
- test-unit
name: Snapshot linux/386
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -110,19 +118,19 @@ jobs:
snapshot_arm64:
if: github.event_name == 'pull_request'
needs:
- tests
- test-unit
name: Snapshot linux/arm64
runs-on: ubuntu-24.04-arm
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -133,19 +141,19 @@ jobs:
snapshot_arm_v7:
if: github.event_name == 'pull_request'
needs:
- tests
- test-unit
name: Snapshot linux/arm/v7
runs-on: ubuntu-24.04-arm
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -182,90 +190,94 @@ jobs:
edge_amd64:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- tests
- test-unit
name: Edge linux/amd64
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: edge
version: pr-${{ github.event.pull_request.number }}
platform: linux/amd64
alternate_repository: snapshot
edge_386:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- tests
- test-unit
name: Edge linux/386
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: edge
version: pr-${{ github.event.pull_request.number }}
platform: linux/386
alternate_repository: snapshot
edge_arm64:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- tests
- test-unit
name: Edge linux/arm64
runs-on: ubuntu-24.04-arm
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: edge
version: pr-${{ github.event.pull_request.number }}
platform: linux/arm64
alternate_repository: snapshot
edge_arm_v7:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- tests
- test-unit
name: Edge linux/arm/v7
runs-on: ubuntu-24.04-arm
outputs:
tags: ${{ steps.build_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_push.outputs.tags_cloud_run }}
tags: ${{ steps.build_test_push.outputs.tags }}
tags_cloud_run: ${{ steps.build_test_push.outputs.tags_cloud_run }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Build and push
id: build_push
uses: ./.github/actions/build-push
- name: Build, test and push
id: build_test_push
uses: ./.github/actions/build-test-push
with:
docker_hub_username: ${{ secrets.DOCKERHUB_USERNAME }}
docker_hub_password: ${{ secrets.DOCKERHUB_TOKEN }}
version: edge
version: pr-${{ github.event.pull_request.number }}
platform: linux/arm/v7
alternate_repository: snapshot
merge_clean_edge_tags:
needs: