-
Notifications
You must be signed in to change notification settings - Fork 465
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
[wip] github-actions: use cache-image in devshell workflow #3798
base: master
Are you sure you want to change the base?
Changes from all commits
e854844
1a92300
c5d9b72
59f0873
3d27e13
217bb0b
26ac33e
6431efc
d6c49c9
16f8cab
e21a1be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Compile dbld-images | ||
|
||
on: | ||
pull_request: | ||
push: | ||
paths: | ||
- .github/workflows/dbld-images.yml | ||
# List is from dbld/rules cache-image-% "WATCHED_FILES" | ||
- "dbld/**" | ||
- "packaging/rhel/syslog-ng.spec" | ||
- "packaging/debian/control" | ||
schedule: | ||
- cron: '00 03 * * *' | ||
workflow_dispatch: | ||
inputs: | ||
upload_images: | ||
description: Should we upload the images into GitHub Packages? (true/false) | ||
required: false | ||
default: "false" | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
CONTAINER_REGISTRY: "ghcr.io/${{ github.repository_owner }}" | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build the images | ||
run: dbld/rules images -j $(nproc) | ||
|
||
- name: Should we upload the images? | ||
run: | | ||
if [ "${{ github.event.inputs.upload_images }}" = "true" ] || \ | ||
( \ | ||
[ "${{ github.repository_owner }}" = "syslog-ng" ] && \ | ||
[ "${{ github.ref }}" = "refs/heads/master" ] && \ | ||
[ "${{ github.event_name }}" = "push" ] \ | ||
) | ||
then | ||
UPLOAD_IMAGES_INTERNAL="true" | ||
else | ||
UPLOAD_IMAGES_INTERNAL="false" | ||
fi | ||
|
||
. .github/workflows/gh-tools.sh | ||
gh_export UPLOAD_IMAGES_INTERNAL | ||
|
||
- name: Log in to the Container registry | ||
if: env.UPLOAD_IMAGES_INTERNAL == 'true' | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push the images | ||
if: env.UPLOAD_IMAGES_INTERNAL == 'true' | ||
run: | | ||
IMAGES=$(docker image ls --filter "reference=${{ env.CONTAINER_REGISTRY }}/dbld-*:latest" --format '{{.Repository}}:{{.Tag}}') | ||
for IMAGE in $IMAGES; do | ||
echo "Pushing image: $IMAGE" | ||
docker push $IMAGE | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,77 @@ | ||
name: CI @ devshell | ||
|
||
on: | ||
pull_request: | ||
pull_request_target: | ||
push: | ||
schedule: | ||
- cron: '00 21 * * *' | ||
|
||
jobs: | ||
cache-image-devshell: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
docker-image: ${{ steps.determine-actual-image.outputs.docker-image }} | ||
|
||
env: | ||
CACHED_IMAGE_NAME: ghcr.io/syslog-ng/dbld-devshell:latest | ||
|
||
steps: | ||
- name: Checkout syslog-ng source | ||
uses: actions/checkout@v2 | ||
|
||
- name: Determine cached image ID | ||
run: | | ||
./dbld/rules pull-image-devshell || true # remove the || true | ||
CACHED_IMAGE_ID=$(docker images -q ${CACHED_IMAGE_NAME}) | ||
|
||
. .github/workflows/gh-tools.sh | ||
gh_export CACHED_IMAGE_ID | ||
|
||
- name: cache-image-devshell | ||
run: | | ||
./dbld/rules cache-image-devshell | ||
|
||
- name: Determine actual image | ||
id: determine-actual-image | ||
run: | | ||
CURRENT_IMAGE_ID=$(docker images -q ${CACHED_IMAGE_NAME}) | ||
if [[ "${CURRENT_IMAGE_ID}" == "${CACHED_IMAGE_ID}" ]] | ||
then | ||
DOCKER_IMAGE=${CACHED_IMAGE_NAME} | ||
USE_CACHED_IMAGE=true | ||
else | ||
DOCKER_IMAGE=ghcr.io/${{ github.actor }}/dbld-devshell:ci-${{ github.run_id }} | ||
USE_CACHED_IMAGE=false | ||
docker tag ${CACHED_IMAGE_NAME} ${DOCKER_IMAGE} | ||
fi | ||
|
||
echo "Using image: ${DOCKER_IMAGE}" | ||
|
||
. .github/workflows/gh-tools.sh | ||
gh_export USE_CACHED_IMAGE | ||
echo "::set-output name=docker-image::${DOCKER_IMAGE}" | ||
|
||
- name: Log in to the Container registry | ||
if: env.USE_CACHED_IMAGE == 'false' | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload the temporary docker image | ||
if: env.USE_CACHED_IMAGE == 'false' | ||
run: | | ||
docker push ${{ steps.determine-actual-image.outputs.docker-image }} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we push this logic into dbld/rules itself? I mean:
I hope I make sense here, my point is if we push this entire logic to dbld/rules, and add a means to communicate information in a structured form, then we might be able to use the same cache-image-* target in all similar cases, avoiding the need to copy steps between github workflows files. What do you think? |
||
general: | ||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-latest | ||
|
||
needs: cache-image-devshell | ||
|
||
container: | ||
image: balabit/syslog-ng-devshell:latest | ||
image: ${{ needs.cache-image-devshell.outputs.docker-image }} | ||
options: --privileged --ulimit core=-1 | ||
|
||
strategy: | ||
|
@@ -144,9 +205,12 @@ jobs: | |
path: ${{ env.COREFILES_DIR }} | ||
|
||
distcheck: | ||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-latest | ||
|
||
needs: cache-image-devshell | ||
|
||
container: | ||
image: balabit/syslog-ng-devshell:latest | ||
image: ${{ needs.cache-image-devshell.outputs.docker-image }} | ||
|
||
steps: | ||
- name: Checkout syslog-ng source | ||
|
@@ -184,9 +248,12 @@ jobs: | |
exec_prop_check "make distcheck -j 3 V=1" | ||
|
||
style-check: | ||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-latest | ||
|
||
needs: cache-image-devshell | ||
|
||
container: | ||
image: balabit/syslog-ng-devshell:latest | ||
image: ${{ needs.cache-image-devshell.outputs.docker-image }} | ||
|
||
steps: | ||
- name: Checkout syslog-ng source | ||
|
@@ -235,9 +302,12 @@ jobs: | |
path: light-style-problems.diff | ||
|
||
copyright-check: | ||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-latest | ||
|
||
needs: cache-image-devshell | ||
|
||
container: | ||
image: balabit/syslog-ng-devshell:latest | ||
image: ${{ needs.cache-image-devshell.outputs.docker-image }} | ||
env: | ||
COPYRIGHTVERBOSITY: 1 | ||
|
||
|
@@ -256,9 +326,12 @@ jobs: | |
path: copyright-run.log | ||
|
||
commits-check: | ||
runs-on: ubuntu-18.04 | ||
runs-on: ubuntu-latest | ||
|
||
needs: cache-image-devshell | ||
|
||
container: | ||
image: balabit/syslog-ng-devshell:latest | ||
image: ${{ needs.cache-image-devshell.outputs.docker-image }} | ||
|
||
steps: | ||
- name: Checkout syslog-ng source | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
`dbld`: move dbld image cache from DockerHub to GitHub | ||
|
||
In 2021, GitHub introduced the GitHub Packages service. Among other | ||
repositories - it provides a standard Docker registry. DBLD can use | ||
such a regsistry, to avoid unnecessary rebuilding of the images. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a left-in TODO?