Upgrade tools #53
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 mysql container" | |
on: | |
pull_request: | |
paths: | |
- "containers/mysql/**" | |
- ".github/workflows/build-mysql-container.yaml" | |
- "!**.md" | |
push: | |
branches: | |
- 'main' | |
paths: | |
- "containers/mysql/**" | |
- ".github/workflows/build-mysql-container.yaml" | |
- "!**.md" | |
jobs: | |
filter: | |
runs-on: ubuntu-20.04 | |
outputs: | |
mysql-versions: ${{ steps.filter.outputs.mysql-versions }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: filter | |
id: filter | |
working-directory: containers | |
run: | | |
array=() | |
for dir in $(find ./mysql -mindepth 1 -type d -printf '%f\n'); do | |
result=$(./tag_exists moco/mysql "mysql/$dir") | |
if [ "$result" = 'ng' ]; then | |
array+=( "$dir" ) | |
fi | |
done | |
json_output=$(echo "${array[@]}" | jq -Rc 'split(" ")') | |
echo "GITHUB_OUTPUT: mysql-versions=$json_output" | |
echo "mysql-versions=$json_output" >> "$GITHUB_OUTPUT" | |
tests: | |
if: ${{ (github.event_name == 'pull_request') && (needs.filter.outputs.mysql-versions != '[]') }} | |
needs: filter | |
runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }} | |
strategy: | |
matrix: | |
mysql-version: ${{ fromJson(needs.filter.outputs.mysql-versions) }} | |
k8s-version: [ "1.27.1" ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker # refs: https://github.com/docker/build-push-action/issues/321 | |
- name: Export TAG file | |
id: tag | |
working-directory: containers | |
run: | | |
TAG=$(cat ./mysql/${{ matrix.mysql-version }}/TAG) | |
echo "tag: $TAG" | |
echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
- uses: docker/build-push-action@v5 | |
with: | |
context: containers/mysql/${{ matrix.mysql-version }}/. | |
push: false | |
load: true | |
tags: | | |
ghcr.io/cybozu-go/moco/mysql:${{ steps.tag.outputs.tag }} | |
ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} | |
- name: Install Container Structure Tests | |
run: | | |
VERSION=v1.15.0 | |
curl -LO "https://storage.googleapis.com/container-structure-test/$VERSION/container-structure-test-linux-amd64" \ | |
&& chmod +x container-structure-test-linux-amd64 \ | |
&& sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test | |
- name: Run Container Structure Tests | |
run: | | |
container-structure-test test --image ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} --config ./containers/mysql/${{ matrix.mysql-version }}/container-structure-test.yaml | |
- run: | | |
swapon > swapon.txt | |
sudo swapoff -a | |
cat swapon.txt | tail -n+2 | awk '$2=="file" {print $1}' | sudo xargs --no-run-if-empty rm | |
- run: sudo mkdir /mnt/local-path-provisioner0 /mnt/local-path-provisioner1 /mnt/local-path-provisioner2 | |
- name: Setup test cluster with local mysql image | |
run: make start KUBERNETES_VERSION=${{ matrix.k8s-version }} MYSQL_VERSION=${{ matrix.mysql-version }} KIND_CONFIG=kind-config_actions.yaml USE_LOCAL_MYSQL_IMAGE=1 | |
working-directory: e2e | |
- run: make test | |
working-directory: e2e | |
- run: make logs | |
working-directory: e2e | |
if: always() | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: logs-${{ matrix.k8s-version }}-${{ matrix.mysql-version }}.tar.gz | |
path: e2e/logs.tar.gz | |
build: | |
if: ${{ (github.ref == 'refs/heads/main') && (needs.filter.outputs.mysql-versions != '[]') }} | |
needs: filter | |
runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }} | |
strategy: | |
matrix: | |
mysql-version: ${{ fromJson(needs.filter.outputs.mysql-versions) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Export TAG file | |
id: tag | |
working-directory: containers | |
run: | | |
TAG=$(cat ./mysql/${{ matrix.mysql-version }}/TAG) | |
echo "tag: $TAG" | |
echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
- uses: docker/build-push-action@v5 | |
with: | |
context: containers/mysql/${{ matrix.mysql-version }}/. | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
ghcr.io/cybozu-go/moco/mysql:${{ steps.tag.outputs.tag }} | |
ghcr.io/cybozu-go/moco/mysql:${{ matrix.mysql-version }} |