Skip to content

Commit

Permalink
#7: Moving to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Nov 14, 2020
1 parent 98938fe commit 1ffa6ad
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 270 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
/.infrastructure/*.Dockerfile
/.venv
*.pyc
.coveragerc
/example
/docs
/tests
25 changes: 25 additions & 0 deletions .github/workflows/test-and-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test and release a package
on: [push]

jobs:
build:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: pip install -r ./requirements.txt

- name: Install project via setuptools
run: "rkd :install"

- name: Run unit tests
run: "rkd :test:unit"

- name: Run functional tests
run: "rkd :test:functional"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
/.idea
*.pyc
/.coverage
.rkd/logs
*__pycache__*
/.venv
.venv-setup.log
13 changes: 8 additions & 5 deletions .infrastructure/x86_64.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.9
FROM alpine:3.12

RUN apk --update add python3 bash perl curl wget grep sed docker sudo mysql-client postgresql-client make git supervisor tzdata \
RUN apk --update add python3 bash perl curl wget grep sed docker sudo mysql-client postgresql-client git supervisor tzdata \
sshpass openssh-client
ADD . /infracheck
ADD .git /infracheck/
Expand All @@ -14,8 +14,11 @@ RUN cd /infracheck \
# install as a package
&& git remote remove origin || true \
&& git remote add origin https://github.com/riotkit-org/infracheck.git \
&& apk add --update gcc python3-dev musl-dev linux-headers postgresql-dev \
&& make install \
\
&& apk add --no-cache --update --virtual BUILD_DEPS py3-pip gcc python3-dev musl-dev linux-headers postgresql-dev libffi-dev \
&& pip3 install pbr==5.4.5 \
&& pip3 install -r /infracheck/requirements.txt \
&& rkd :install \
# after installing as package extract infrastructural files
\
&& cp -pr /infracheck/entrypoint.sh / \
Expand All @@ -28,6 +31,6 @@ RUN cd /infracheck \
# simple check that application does not crash at the beginning (is correctly packaged)
&& infracheck --help \
\
&& apk del gcc python3-dev musl-dev linux-headers postgresql-dev
&& apk del BUILD_DEPS

ENTRYPOINT ["/entrypoint.sh"]
81 changes: 81 additions & 0 deletions .rkd/makefile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
version: org.riotkit.rkd/yaml/v1
imports:
- rkd_python

environment:
REPO: "quay.io/riotkit/infracheck"

tasks:
:test:unit:
description: Run unit tests
steps:
- "%RKD% :py:unittest --src-dir=./ --tests-dir=tests --pattern='unit_test_*.py'"

:test:functional:
description: Run unit tests
steps:
- "python -m unittest discover -s . -p 'functional_test*.py'"
- "cd infracheck && ./functional-test.sh"

:install:
description: Install via setuptools
steps:
- python3 ./setup.py install

:image:
description: Build a docker image
arguments:
"--git-tag":
help: "Will tag the image considering this version"
required: False
"--push":
help: "Push or only build?"
action: store_true
"--arch":
help: "Architecture name"
default: "x86_64"
steps: |
#!python
tag = ctx.get_arg('--git-tag')
should_push = ctx.get_arg('--push')
arch = ctx.get_arg('--arch')
docker_tag = 'latest-dev-' + arch
repo = os.getenv('REPO')
if tag:
docker_tag = arch + '-' + tag
image_name = '{repo}:{tag}'.format(tag=docker_tag, repo=repo)
this.sh('docker build . -f ./.infrastructure/{docker_arch}.Dockerfile -t {image}'
.format(docker_arch=arch, image=image_name))
this.sh('docker tag {image} {image}-$(date "+%Y-%m-%d")'.format(image=image_name))
if should_push:
this.sh('docker push {image}'.format(image=image_name))
this.sh('docker push {image}-$(date "+%Y-%m-%d")'.format(image=image_name))
:release:pypi:
description: Release to PyPI
steps:
- "%RKD% :py:build"
- "%RKD% :py:publish --password=${PYPI_PASSWORD} --username=__token__ --skip-existing"

:release:docker:x86:
description: Release into docker registry (x86 image)
arguments:
"--git-tag":
help: "Git tag name"
required: true
steps:
- "%RKD% :image --push --git-tag=${ARG_GIT_TAG} --arch=x86_64"

:release:docker:arm:
description: Release into docker registry (arm image)
arguments:
"--git-tag":
help: "Git tag name"
required: true
steps:
- "%RKD% :image --push --git-tag=${ARG_GIT_TAG} --arch=arm"
19 changes: 0 additions & 19 deletions Pipfile

This file was deleted.

Loading

0 comments on commit 1ffa6ad

Please sign in to comment.