diff options
author | 2020-11-16 21:01:42 +0100 | |
---|---|---|
committer | 2020-11-16 21:01:42 +0100 | |
commit | 514c4b4148d0c25894965662b87940868a59389c (patch) | |
tree | a9d7d8182a59f0a7a3b64c04be1ede939e0aceda | |
parent | Merge pull request #78 - Update to Python 3.9 (diff) |
Test workflow build strategy
-rw-r--r-- | .github/.github/workflows/lint-test.yaml | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/.github/.github/workflows/lint-test.yaml b/.github/.github/workflows/lint-test.yaml new file mode 100644 index 0000000..af8c91e --- /dev/null +++ b/.github/.github/workflows/lint-test.yaml @@ -0,0 +1,83 @@ +name: Build, Lint, Test + +on: + push: + branches: + - master + + +jobs: + lint-test: + runs-on: ubuntu-latest + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Github Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: Cache Base Image Layers + uses: actions/cache@v2 + with: + path: /tmp/.base-buildx-cache + key: ${{ runner.os }}-buildx-base-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-base- + + - name: Cache Venv Image Layers + uses: actions/cache@v2 + with: + path: /tmp/.venv-buildx-cache + key: ${{ runner.os }}-buildx-venv-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-venv- + + - name: Build base image + uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/base.Dockerfile + push: false + cache-from: type=local,src=/tmp/.base-buildx-cache + cache-to: type=local,type=local,dest=/tmp/.base-buildx-cache,mode=max + tags: ghcr.io/python-discord/snekbox-base:latest + + - name: Build venv image + uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/venv.Dockerfile + push: false + cache-from: type=local,src=/tmp/.venv-buildx-cache + cache-to: type=local,type=local,dest=/tmp/.venv-buildx-cache,mode=max + tags: ghcr.io/python-discord/snekbox-venv:latest + + - name: Start Container + run: docker run \ + --tty \ + --detach \ + --name snekbox_test \ + --privileged \ + --hostname pdsnk-dev \ + -e PYTHONDONTWRITEBYTECODE=1 \ + -e PIPENV_PIPFILE="/snekbox/Pipfile" \ + -e ENV="${PWD}/scripts/.profile" \ + --volume "${PWD}":"${PWD}" \ + --workdir "${PWD}"\ + --entrypoint /bin/bash \ + pythondiscord/snekbox-venv:latest + + - name: Install dependencies + run: | + docker exec snekbox_test /bin/bash -c \ + 'pipenv install --system --deploy --dev' + + - name: Run linter + run: | + docker exec snekbox_test /bin/bash -c 'flake8 \ + --format "::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s"' |