Skip to content

Commit

Permalink
Enable Drone to create and use different cache images per branch
Browse files Browse the repository at this point in the history
Additionally (see comment in .drone.yml):
1) Cache will now be built automatically if none was found
   (this required manual intervention before)
2) Cache will now be rebuilt automatically if cache-defining files
   have been changed
3) It is now possible to manually force a cache rebuild by *promoting*
   a build (can be done from the web interface)
4) *Any* cron job on the branch will now trigger a cache rebuild

All of the above logic is done using a (hacky for Drone, but as clean
as I could get it for shell) "one-liner" and can, of course, easily be
changed.

Squashed commit of the following:

commit 7d582c10fdc048937be792ed884ca23da98b6541
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 21:32:18 2023 +0200

    Remove temporary diagnostic steps

commit ae466ac
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 21:12:52 2023 +0200

    Revert "Slim Dockerfile for testing"

    This reverts commit a368a0e.

commit 40d793d
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 21:11:00 2023 +0200

    Add a missing dependency

commit d4f403b
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 21:02:41 2023 +0200

    More test commands

commit a368a0e
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 20:57:42 2023 +0200

    Slim Dockerfile for testing

commit 2640d7c
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 20:21:44 2023 +0200

    Re-enable slack notifications

commit b5dac29
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 20:11:48 2023 +0200

    Remove redundant step run condition

commit f87b601
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 20:11:37 2023 +0200

    Better comments [ci skip]

commit 0251305
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 19:54:40 2023 +0200

    Fix drone cache naming scheme

commit 3cc6736
Author: Ilia Zaichuk <[email protected]>
Date:   Wed Feb 1 19:51:03 2023 +0200

    Hacky shell for drone cache

commit c272db7
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 17:39:32 2023 +0200

    Fix forgotten variable

commit 78ba7f0
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 17:21:55 2023 +0200

    Revert "Ambitious drone global envrionment attempt"

    This reverts commit adb451a.

commit adb451a
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 17:18:28 2023 +0200

    Ambitious drone global envrionment attempt

commit 3de856b
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 17:08:09 2023 +0200

    Drone template semifinal

commit d547e0d
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 17:00:13 2023 +0200

    Drone templates #3.2

commit c4718df
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 16:57:40 2023 +0200

    Drone templates #3.1

commit 5b3ea36
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 16:55:11 2023 +0200

    Drone templates #3

commit 9bb02ff
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 16:49:01 2023 +0200

    Revert "Another attempt at drone templates"

    This reverts commit 2d57178.

commit 2d57178
Author: Ilia Zaichuk <[email protected]>
Date:   Mon Jan 30 16:43:40 2023 +0200

    Another attempt at drone templates

commit 5c90a9b
Author: Ilia Zaichuk <[email protected]>
Date:   Fri Jan 27 20:39:49 2023 +0200

    Test a variable *directly* from the docs

commit 8afc14d
Author: Ilia Zaichuk <[email protected]>
Date:   Fri Jan 27 16:26:39 2023 +0200

    Decrease redundancy in step names

commit 22ed1d0
Author: Ilia Zaichuk <[email protected]>
Date:   Fri Jan 27 15:13:41 2023 +0200

    Add more variable tests to drone pipeline

commit 62891da
Author: Ilia Zaichuk <[email protected]>
Date:   Fri Jan 27 15:12:30 2023 +0200

    Set up test drone pipeline

commit b2eeae0
Author: Ilia Zaichuk <[email protected]>
Date:   Fri Jan 27 15:06:40 2023 +0200

    Lint CI-related files
  • Loading branch information
zoickx committed Feb 1, 2023
1 parent bf225dd commit 47f4362
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
46 changes: 27 additions & 19 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
---
kind: pipeline
type: docker
name: default

# Note: DRONE_ variables are subject to substitution by Drone before execution
# (see [https://docs.drone.io/pipeline/environment/substitution])
steps:
- name: submodules
image: alpine/git
commands:
- git submodule update --init --recursive

# Cache will be (re)built if:
# 1) the build was triggered by a cron job, or was promoted (web interface: top right "..." -> "Promote")
# 2) no image is found with the tag expected for this repo+branch
# 3) cache definition files have changed since the last build (filenames hardcoded below)
- name: rebuild-cache
image: docker
image: docker:git
volumes:
- name: dockersock
path: /var/run/docker.sock
commands:
- docker build --no-cache -t helix-cache .
when:
event:
- cron
cron:
- rebuild-cache
- |
if [ '${DRONE_BUILD_EVENT}' = cron ] || [ '${DRONE_BUILD_EVENT}' = promote ] || \
[ -z "$(docker image ls --quiet 'cache--${DRONE_REPO_NAME}--${DRONE_BRANCH}')" ] || \
! git diff --quiet --exit-code ${DRONE_COMMIT_BEFORE}..${DRONE_COMMIT_AFTER} Dockerfile helix.opam ; \
then \
docker build --no-cache -t 'cache--${DRONE_REPO_NAME}--${DRONE_BRANCH}' . ; \
fi
- name: submodules
image: alpine/git
commands:
- git submodule update --init --recursive

- name: build-vellvm
image: helix-cache
image: cache--${DRONE_REPO_NAME}--${DRONE_BRANCH}
pull: never
commands:
- opam exec -- make -j 1 vellvm

- name: compile-helix
image: helix-cache
image: cache--${DRONE_REPO_NAME}--${DRONE_BRANCH}
pull: never
commands:
- opam exec -- make

- name: test-helix
image: helix-cache
image: cache--${DRONE_REPO_NAME}--${DRONE_BRANCH}
pull: never
commands:
- opam exec -- make test
Expand All @@ -45,10 +53,10 @@ steps:
webhook:
from_secret: slack_webhook
channel: bitbucket-activity
when:
status:
- failure
- success
when:
status:
- failure
- success

volumes:
- name: dockersock
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ FROM ubuntu:22.04
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90assumeyes
ARG OPAMYES=true

RUN apt update
RUN apt upgrade
RUN apt install opam
RUN apt-get update
RUN apt-get upgrade
RUN apt-get install opam

RUN opam init --bare --disable-sandboxing
RUN opam switch create helix ocaml-base-compiler \
Expand Down

0 comments on commit 47f4362

Please sign in to comment.