Skip to content

Commit

Permalink
Be less aggressive about Docker and docs builds
Browse files Browse the repository at this point in the history
Only trigger the Docker build workflow for ticket branches and tags.
Only trigger docs builds for ticket branches and the main branch,
and ignore commits that don't touch the documentation.

This should cut back on the useless Docker images and docuemntation
versions we push from dependency updates from dependabot and
neophile.

We'd like to preserve the behavior of only triggering Docker builds
if the tests pass, but unfortunately there isn't any way to do that
and also use different criteria for running the Docker workflow
without some very complicated machinations involving the REST API or
complex conditionals.  Live with spurious builds with failing tests
for now at least.
  • Loading branch information
rra committed Mar 9, 2021
1 parent 0493431 commit aca1cc5
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 67 deletions.
68 changes: 1 addition & 67 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push]
"on": [push]

jobs:
test:
Expand Down Expand Up @@ -89,69 +89,3 @@ jobs:
- name: Run tox (PostgreSQL)
run: tox -e docker
if: matrix.database == 'PostgreSQL'

build:
runs-on: ubuntu-latest
needs: [test]

steps:
- uses: actions/checkout@v2

- name: Define the Docker tag
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF} | sed -E 's,refs/(heads|tags)/,,' | sed -E 's,/,-,g')

- name: Print the tag
id: print
run: echo ${{steps.vars.outputs.tag}}

- name: Log into Docker Hub
run: echo ${{ secrets.DOCKER_TOKEN }} | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Pull previous images
run: |
docker pull lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}} || true
docker pull lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}} || true
- name: Build the dependencies Docker image
run: |
docker build --target dependencies-image \
--cache-from=lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}} \
--tag lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}} .
- name: Build the runtime Docker image
run: |
docker build --target runtime-image \
--cache-from=lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}} \
--tag lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}} .
- name: Push Docker images
run: |
docker push lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}}
docker push lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}}
docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

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

- name: Install tox and LTD Conveyor
run: pip install tox ltd-conveyor

- name: Install graphviz and ImageMagick
run: sudo apt-get install graphviz imagemagick

- name: Run tox
run: tox -e docs

- name: Upload to LSST the Docs
env:
LTD_USERNAME: ${{ secrets.LTD_USERNAME }}
LTD_PASSWORD: ${{ secrets.LTD_PASSWORD }}
run: ltd upload --product gafaelfawr --gh --dir docs/_build/html
48 changes: 48 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker

"on":
push:
branches:
- "tickets/**"
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Define the Docker tag
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF} | sed -E 's,refs/(heads|tags)/,,' | sed -E 's,/,-,g')

- name: Print the tag
id: print
run: echo ${{steps.vars.outputs.tag}}

- name: Log into Docker Hub
run: echo ${{ secrets.DOCKER_TOKEN }} | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Pull previous images
run: |
docker pull lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}} || true
docker pull lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}} || true
- name: Build the dependencies Docker image
run: |
docker build --target dependencies-image \
--cache-from=lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}} \
--tag lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}} .
- name: Build the runtime Docker image
run: |
docker build --target runtime-image \
--cache-from=lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}} \
--tag lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}} .
- name: Push Docker images
run: |
docker push lsstsqre/gafaelfawr:deps-${{steps.vars.outputs.tag}}
docker push lsstsqre/gafaelfawr:${{steps.vars.outputs.tag}}
38 changes: 38 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docs

"on":
push:
branches:
- main
- master
- "tickets/**"
paths:
- "docs/**"
- "src/**.py"

jobs:
docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

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

- name: Install tox and LTD Conveyor
run: pip install tox ltd-conveyor

- name: Install graphviz and ImageMagick
run: sudo apt-get install graphviz imagemagick

- name: Run tox
run: tox -e docs

- name: Upload to LSST the Docs
env:
LTD_USERNAME: ${{ secrets.LTD_USERNAME }}
LTD_PASSWORD: ${{ secrets.LTD_PASSWORD }}
run: ltd upload --product gafaelfawr --gh --dir docs/_build/html

0 comments on commit aca1cc5

Please sign in to comment.