Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update Docker workflow to build-push-action v2 #1441

Merged
merged 26 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e6ba29c
Add seperate Docker workflow
matthewfeickert May 10, 2021
1615802
Update workflow to also test
matthewfeickert May 10, 2021
d93b569
Remove docker workflow that was added
matthewfeickert May 10, 2021
167d990
Add testing of images
matthewfeickert May 10, 2021
c7bba0a
Remove Docker tests from CI
matthewfeickert May 10, 2021
650edef
Add check for PR
matthewfeickert May 10, 2021
3edf8fe
rename
matthewfeickert May 10, 2021
760d672
Rename workflow to docker
matthewfeickert May 10, 2021
edf31f1
Add cron
matthewfeickert May 10, 2021
70e5c77
comment out push restrictions for tests
matthewfeickert May 10, 2021
00f6fd4
make ids unique
matthewfeickert May 10, 2021
595d4fd
Do releases of images on GitHub releases
matthewfeickert May 10, 2021
7e15257
Use new API
matthewfeickert May 10, 2021
b1e9522
Automatic tagging with sha no longer supported by default
matthewfeickert May 10, 2021
d229445
Use DockerHub access token
matthewfeickert May 10, 2021
04d2f22
Add QEMU to see if it matters
matthewfeickert May 10, 2021
267a137
Use path context for git scm to work
matthewfeickert May 10, 2021
ea4b3be
load to local context
matthewfeickert May 10, 2021
929369a
Set tags based off of situation
matthewfeickert May 10, 2021
42ba15f
add labels
matthewfeickert May 10, 2021
eb38afc
Update tags available
matthewfeickert May 10, 2021
00b6458
try using sha for test tag
matthewfeickert May 10, 2021
851f1fa
Remove refs/heads as tags
matthewfeickert May 10, 2021
55e85eb
Uncomment on master and tags only
matthewfeickert May 10, 2021
1972c73
Update docker image to python:3.8-slim
matthewfeickert May 10, 2021
c887a71
fix step id
matthewfeickert May 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,3 @@ jobs:
if: github.event_name == 'schedule' && matrix.python-version == 3.8
run: |
python -m pytest -r sx --benchmark-sort=mean tests/benchmarks/test_benchmark.py

docker:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build Docker image
uses: docker/build-push-action@v1
with:
repository: pyhf/pyhf
dockerfile: docker/Dockerfile
tags: test
tag_with_sha: true
tag_with_ref: true
push: false
- name: List built images
run: docker images
- name: Run CLI API check
run: |
printf "\npyhf\n"
docker run --rm pyhf/pyhf:test
printf "\npyhf --version\n"
docker run --rm pyhf/pyhf:test --version
printf "\npyhf --help\n"
docker run --rm pyhf/pyhf:test --help
- name: Check for curl and tar
run: >-
docker run --rm
--entrypoint /bin/bash
pyhf/pyhf:test
-c "which curl; which tar"
123 changes: 123 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Docker Images

on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master
schedule:
- cron: '1 0 * * *'
release:
types: [published]
workflow_dispatch:

jobs:
docker:
name: Build, test, and publish Docker images to Docker Hub
runs-on: ubuntu-latest

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

- name: Prepare
id: prep
run: |
DOCKER_IMAGE=pyhf/pyhf
VERSION=latest
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
TAGS="$TAGS,${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
if [ "${{ github.event_name }}" = "release" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest-stable"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Test build
id: docker_build_test
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
load: true
push: false

- name: Image digest
run: echo ${{ steps.docker_build_test.outputs.digest }}

- name: List built images
run: docker images

- name: Run CLI API check
run: |
printf "\npyhf\n"
docker run --rm pyhf/pyhf:sha-${GITHUB_SHA::8}
printf "\npyhf --version\n"
docker run --rm pyhf/pyhf:sha-${GITHUB_SHA::8} --version
printf "\npyhf --help\n"
docker run --rm pyhf/pyhf:sha-${GITHUB_SHA::8} --help

- name: Check for curl and tar
run: >-
docker run --rm
--entrypoint /bin/bash
pyhf/pyhf:sha-${GITHUB_SHA::8}
-c "which curl; which tar"

- name: Build and publish to registry
# every PR will trigger a push event on master, so check the push event is actually coming from master
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'scikit-hep/pyhf'
id: docker_build_latest
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
tags: pyhf/pyhf:latest
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
load: true
push: true

- name: Build and publish to registry with release tag
if: github.event_name == 'release' && github.event.action == 'published' && github.repository == 'scikit-hep/pyhf'
id: docker_build_release
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
load: true
push: true
36 changes: 0 additions & 36 deletions .github/workflows/publish-docker.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=python:3.7-slim
ARG BASE_IMAGE=python:3.8-slim
# hadolint ignore=DL3006
FROM ${BASE_IMAGE} as base

Expand Down