Skip to content

Commit

Permalink
Enable GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rycus86 committed Apr 4, 2022
1 parent 4232a7b commit 24d874e
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 4 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Test & publish package

on: [push, pull_request]

jobs:

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ 2.7, 3.5, 3.6, 3.7, 3.8, 3.9 ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage coveralls
pip install -r requirements.txt
pip install -r docker-requirements.txt
- name: Run tests
run: |
PYTHONPATH=src python -m coverage run --branch --source=src -m unittest discover -s tests -v
- name: Upload coverage report
if: always() && matrix.python-version == '3.9'
run: |
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

integration:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Run integration tests
run: |
pip install -r requirements.txt
pip install -r docker-requirements.txt
DIND_VERSION=18.09 PYTHONPATH=tests python -m unittest discover -s tests -v -p it_*.py
deploy:
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
include:
- BASE_IMAGE: alpine
DOCKER_TAG: amd64

- BASE_IMAGE: rycus86/armhf-alpine-qemu
DOCKER_TAG: armhf

- BASE_IMAGE: rycus86/arm64v8-alpine-qemu
DOCKER_TAG: aarch64

- BASE_IMAGE: alpine
DOCKER_TAG: amd64-docker
FLAVOR: -docker

- BASE_IMAGE: rycus86/armhf-alpine-qemu
DOCKER_TAG: armhf-docker
FLAVOR: -docker

- BASE_IMAGE: rycus86/arm64v8-alpine-qemu
DOCKER_TAG: aarch64-docker
FLAVOR: -docker
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log into registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Get the current branch name
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
id: vars

- name: Prepare multiarch build
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
- name: Build and push Docker image ${{ matrix.DOCKER_TAG }}
uses: docker/build-push-action@v2
with:
push: ${{ github.event_name != 'pull_request' && steps.vars.outputs.branch == 'master' }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/webhook-proxy:${{ matrix.DOCKER_TAG }}
context: .
file: Dockerfile$FLAVOR
build-args: |
BASE_IMAGE=${{ matrix.BASE_IMAGE }}
GIT_COMMIT=$GITHUB_SHA
manifest:
runs-on: ubuntu-latest
needs: deploy
steps:
- uses: actions/checkout@v2
- name: Log into registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Upload manifest
run: |
curl -fsSL https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64 > ./manifest-tool
chmod +x ./manifest-tool
./manifest-tool push from-spec manifest.yml
./manifest-tool push from-spec manifest-docker.yml
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ ENTRYPOINT [ "python", "app.py"]
# add app info as environment variables
ARG GIT_COMMIT
ENV GIT_COMMIT $GIT_COMMIT
ARG BUILD_TIMESTAMP
ENV BUILD_TIMESTAMP $BUILD_TIMESTAMP
2 changes: 0 additions & 2 deletions Dockerfile-docker
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ ENTRYPOINT [ "python", "app.py"]
# add app info as environment variables
ARG GIT_COMMIT
ENV GIT_COMMIT $GIT_COMMIT
ARG BUILD_TIMESTAMP
ENV BUILD_TIMESTAMP $BUILD_TIMESTAMP

0 comments on commit 24d874e

Please sign in to comment.