Skip to content

Commit

Permalink
Add github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jlubken committed Jun 2, 2020
1 parent 00e24af commit c6e95a8
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
release:
type: [ created ]

jobs:

build:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v2

- name: version
run: |
# Tagged release
if [[ ${{ github.ref }} == refs/tags/* ]]; then
# Strip git ref prefix from $VERSION
TAGNAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
VERSION=$(echo $TAGNAME | sed -e 's/^v//')
else
VERSION=${{ github.sha }}
fi
echo "::set-env name=VERSION::$VERSION"
echo "Version: $VERSION"
export DOCKER_BUILDKIT=1
- name: lint
run: |
docker-compose -f docker-compose.lint.yml up
docker-compose -f docker-compose.lint.yml down
- name: test
run: |
docker-compose -f docker-compose.test.yml up
docker-compose -f docker-compose.test.yml down
- name: image
run: |
VERSION="${{ env.VERSION }}"
TARGETS="lint test"
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
for TARGET in $TARGETS
do
docker build -f dockerfile . --target $TARGET -t $TARGET
IMAGE=$(docker inspect --format '{{ .Config.Env }}' $TARGET | tr -d '[]' | tr ' ' '\n' | grep IMAGE | sed 's/^.*=//')
echo "Image: $IMAGE"
PUSH="docker.pkg.github.com/${{ github.repository }}/$IMAGE:$VERSION"
echo "Push: $PUSH"
docker tag $TARGET $PUSH
docker push $PUSH
done
13 changes: 13 additions & 0 deletions docker-compose.lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.7"
services:

test:
image: lint
build:
context: .
dockerfile: dockerfile
target: lint
volumes:
- ./local:/local:ro
- ./model:/model:ro
- ./secrets:/secrets:ro
13 changes: 13 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.7"
services:

test:
image: test
build:
context: .
dockerfile: dockerfile
target: test
volumes:
- ./local:/local:ro
- ./model:/model:ro
- ./secrets:/secrets:ro
43 changes: 43 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
ARG IFLAGS="--quiet --no-cache-dir --user"

FROM python:3.7.7-slim-buster as build
ARG IFLAGS
WORKDIR /root
ENV FREETDS /root/freetds.conf
ENV PATH /root/.local/bin:$PATH
ENV TINI_VERSION v0.16.1
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
COPY CHANGELOG.rst .
COPY README.rst .
COPY freetds.conf .
COPY setup.cfg .
COPY setup.py .
COPY pyproject.toml .
COPY .pre-commit-config.yaml .
COPY .pylintrc .
COPY .git ./.git
COPY src ./src
COPY test ./test
RUN \
chmod +x /usr/bin/tini && \
apt-get update --fix-missing && \
apt-get install -y --no-install-recommends git && \
pip install ${IFLAGS} "." && \
apt-get clean && \
apt-get autoremove -y --purge && \
rm -rf /var/lib/apt/lists/*

FROM build as lint
ARG IFLAGS
WORKDIR /root
ENV IMAGE dsdk.lint
RUN \
pip install ${IFLAGS} ".[all]"
ENTRYPOINT [ "/usr/bin/tini", "--" ]
CMD [ "pre-commit", "run", "--all-files" ]

FROM lint as test
WORKDIR /root
ENV IMAGE dsdk.test
ENTRYPOINT [ "/usr/bin/tini", "--" ]
CMD [ "python", "setup.py", "test" ]
4 changes: 4 additions & 0 deletions freetds.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[global]
client charset = UTF-8
tds version = 7.4
use ntlmv2 = yes

0 comments on commit c6e95a8

Please sign in to comment.