Use docker buildx image tool for the main image #6
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: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
product_name: db-operator | |
go_version: "1.21" | |
go_os: linux | |
go_arch: amd64 | |
main_go_path: . | |
jobs: | |
lint: ## https://github.com/golangci/golangci-lint-action#how-to-use | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup GO | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Check Code Style | |
run: make lint | |
unit-test: | |
runs-on: ubuntu-latest | |
needs: lint | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
# The existing apparmor profile for mysql needs to be removed. | |
# https://github.com/actions/virtual-environments/issues/181 | |
# https://github.com/moby/moby/issues/7512#issuecomment-51845976 | |
- name: Run the unit tests | |
run: go test -tags tests -run "TestUnit" ./... -v -cover | |
kubernetes-tests: | |
runs-on: ubuntu-latest | |
needs: lint | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Prepare the test environment | |
run: make envtest | |
- name: Run the kubernetes integration tests | |
run: go test -tags tests -run "TestKubernetes" ./... -v -cover | |
gsql-test: | |
runs-on: ubuntu-latest | |
needs: lint | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Start dependencies using docker-compose | |
run: docker-compose -f ./resources/test/docker-compose-gsql.yml up -d | |
- name: Run gsql tests | |
run: go test -tags tests -run "TestGsql" ./... -v -cover | |
mysql-test: | |
runs-on: ubuntu-latest | |
needs: lint | |
strategy: | |
matrix: | |
image: | |
- mysql:5.7 | |
- mysql:8.0 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
# The existing apparmor profile for mysql needs to be removed. | |
# https://github.com/actions/virtual-environments/issues/181 | |
# https://github.com/moby/moby/issues/7512#issuecomment-51845976 | |
- name: Remove MySQL App Armour Configuration | |
run: | | |
set -x | |
sudo apt-get update | |
sudo apt-get remove mysql-server --purge | |
sudo apt-get install apparmor-profiles | |
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld | |
- name: Run the unit tests | |
run: ./scripts/test_database -d mysql -i ${{ matrix.image }} -f ./resources/test/docker-compose-mysql-tmpl.yml | |
mariadb-test: | |
runs-on: ubuntu-latest | |
needs: lint | |
strategy: | |
matrix: | |
image: | |
- mariadb:10.10 | |
- mariadb:10.11 | |
- mariadb:11.0 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
# The existing apparmor profile for mysql needs to be removed. | |
# https://github.com/actions/virtual-environments/issues/181 | |
# https://github.com/moby/moby/issues/7512#issuecomment-51845976 | |
- name: Remove MySQL App Armour Configuration | |
run: | | |
set -x | |
sudo apt-get update | |
sudo apt-get remove mysql-server --purge | |
sudo apt-get install apparmor-profiles | |
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld | |
- name: Run the unit tests | |
run: ./scripts/test_database -d mysql -i ${{ matrix.image }} -f ./resources/test/docker-compose-mariadb-tmpl.yml | |
postgres-test: | |
runs-on: ubuntu-latest | |
needs: lint | |
strategy: | |
matrix: | |
image: | |
- postgres:16 | |
- postgres:15 | |
- postgres:14 | |
- postgres:13 | |
- postgres:12 | |
- postgres:11 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Run the unit tests | |
run: ./scripts/test_database -d postgres -i ${{ matrix.image }} -f ./resources/test/docker-compose-postgres-tmpl.yml | |
# ------------------------------------------------------------------- | |
# -- Azure Flexible Postgres test | |
# -- Azure doesn't give you a super-admin user, so there is an init | |
# -- script that imitates the Azure Flexible Server behaviour | |
# ------------------------------------------------------------------- | |
postgres-az-test: | |
runs-on: ubuntu-latest | |
needs: lint | |
strategy: | |
matrix: | |
image: | |
# -- Trusted extensions were added only in 13, we need them for tests | |
- postgres:14 | |
- postgres:13 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Run the unit tests | |
run: ./scripts/test_database -d postgres -i ${{ matrix.image }} -f ./resources/test/docker-compose-az-flexible-postgres-tmpl.yml |