Skip to content

Commit

Permalink
Merge pull request #402 from Kegbot/mikey/docker-workflows
Browse files Browse the repository at this point in the history
Update actions
  • Loading branch information
mik3y authored May 1, 2020
2 parents f058a75 + 5638886 commit 2319404
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 99 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/docker-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Docker Build (amd64)

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
-
name: Available platforms
run: echo ${{ steps.build.outputs.platforms }}
-
name: Build
run: |
docker buildx build \
--platform linux/amd64 \
-t current \
--load .
-
name: Login to DockerHub Registry
if: success() && github.ref == 'refs/heads/master'
run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
-
name: Tag as latest
if: success() && github.ref == 'refs/heads/master'
run: |
docker tag current kegbot/server:latest
-
name: Publish
if: success() && github.ref == 'refs/heads/master'
run: |
docker push kegbot/server:latest
47 changes: 47 additions & 0 deletions .github/workflows/docker-arm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Docker Build (armv7)

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
-
name: Available platforms
run: echo ${{ steps.build.outputs.platforms }}
-
name: Build
run: |
docker buildx build \
--platform linux/arm/v7 \
-t current \
--load .
-
name: Login to DockerHub Registry
if: success() && github.ref == 'refs/heads/master'
run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
-
name: Tag as latest-arm
if: success() && github.ref == 'refs/heads/master'
run: |
docker tag current kegbot/server:latest-arm
-
name: Publish
if: success() && github.ref == 'refs/heads/master'
run: |
docker push kegbot/server:latest-arm
33 changes: 0 additions & 33 deletions .github/workflows/dockerbuildx.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/dockerimage.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/dockerpublish.yml

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/pybuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Python Build & Test

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
py_build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install dependencies
run: |
pip install pipenv docker-compose
pipenv install --deploy --dev
- name: Run mysql & redis
run: |
docker-compose -f testdata/test-docker-compose.yml up -d
sleep 10 && ./bin/wait-for-container.sh testdata_mysql_1
- name: pytest
run: KEGBOT_DATABASE_URL=mysql://root:[email protected]:3306/kegbot_dev pipenv run pytest
28 changes: 28 additions & 0 deletions bin/wait-for-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

MAX_ATTEMPTS=60

function getContainerHealth {
docker inspect --format "{{.State.Health.Status}}" $1
}

function waitContainer {
attempts=0
while STATUS=$(getContainerHealth $1); [ $STATUS != "healthy" ]; do
if [ $STATUS == "unhealthy" ]; then
echo "container is unhealthy"
exit -1
fi
echo "container $1: status $STATUS ..."
lf=$'\n'
attempts=$[$attempts+1]
if [ $attempts -ge $MAX_ATTEMPTS ]; then
echo "Max attempts reached; fail"
exit -1
fi
sleep 1
done
echo "Container is up!"
}

waitContainer $1
32 changes: 32 additions & 0 deletions testdata/test-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# docker-compose for use in continuous integration
# Not for production!

version: '3'
services:
mysql:
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'changeme'
MYSQL_USER: 'kegbot_dev'
MYSQL_PASSWORD: 'changeme'
MYSQL_DATABASE: 'kegbot_dev'
healthcheck:
test: ["CMD", "mysqladmin", "ping", "--silent"]
interval: 10s
timeout: 10s
retries: 3
volumes:
- mysql-data:/var/lib/mysql
ports:
- "3306:3306"

redis:
image: redis:latest
restart: always
ports:
- "6379:6379"

volumes:
mysql-data:
kegbot-data:

0 comments on commit 2319404

Please sign in to comment.