Skip to content

CI Refactor#133

Merged
MarkKoz merged 19 commits into
mainfrom
ci-refactor
Feb 13, 2022
Merged

CI Refactor#133
MarkKoz merged 19 commits into
mainfrom
ci-refactor

Conversation

@MarkKoz
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz commented Dec 27, 2021

The workflow is broken up into separate reusable workflows. No more of the monolithic workflow file! Another consequence is that the lint workflow can run concurrently with the build workflow, since linting doesn't depend on the build.

The build uploads a tarball of the Docker image as an artefact so that other workflows can download the artefact and start a container. For tests, the coverage results from each OS in the matrix are combined into one and finally published.

I think the overall duration of the new workflow shouldn't be much longer than the current workflow, especially due to being able to run linting in parallel despite the additional dependency install taking more time.

@MarkKoz MarkKoz added type: feature New feature or request status: WIP Work in progress area: CI Related to continuous intergration and deployment labels Dec 27, 2021
@MarkKoz MarkKoz force-pushed the ci-refactor branch 3 times, most recently from c6bca44 to 5e53fca Compare December 27, 2021 03:40
load: true was already creating a tarball, but it was getting
immediately loaded. Since no other Docker builds run in this job,
it's useless to load it. The action can still be leveraged to create
the tarball instead of manually invoking `docker save`.
Make the artefact and file names identical to simplify things. The
artefact name doesn't have to be unique anyway since it can only be
downloaded by the same workflow run.
@MarkKoz MarkKoz force-pushed the ci-refactor branch 2 times, most recently from 6c9252e to 238af38 Compare December 27, 2021 05:13
@coveralls
Copy link
Copy Markdown

coveralls commented Dec 27, 2021

Coverage Status

Coverage increased (+5.3%) to 84.0% when pulling e3aada0 on ci-refactor into 2f70b8b on main.

Unlike the cache action, the build-push action's GHA cache feature
seems to only do an exact comparison for the scope. Thus, new commits
lead to cache misses.
@MarkKoz MarkKoz force-pushed the ci-refactor branch 2 times, most recently from 921ebe6 to 139f325 Compare December 27, 2021 07:24
Remove the dependency on the container so the lint job can run in
parallel with the build job. More time has to be spent installing
Python dependencies, but this is made up for by not having to download
and load the image artefact in addition to not having to wait for the
build job.
The step was running even if the pre-commit hooks step never ran.
Use docker-compose run instead of docker-compose up. This is more
appropriate since the container is only needed for one command. The
latter was actually starting the whole snekbox server. Furthermore,
the former has the --rm option to remove the container when the command
finishes.

As an extra precaution, use docker-compose down in the self-hosted
runner to also remove images, volumes, networks, and any other
containers that were somehow missed. Removing images will also prevent
the disk usage from building up. This is not necessary for the GH-hosted
runner since a new VM is used for each run.
@MarkKoz MarkKoz force-pushed the ci-refactor branch 5 times, most recently from 12a5767 to 016b83d Compare December 28, 2021 01:36
@MarkKoz MarkKoz removed the status: WIP Work in progress label Feb 13, 2022
@MarkKoz MarkKoz marked this pull request as ready for review February 13, 2022 06:19
@MarkKoz MarkKoz requested review from Den4200 and jb3 as code owners February 13, 2022 06:19
Copy link
Copy Markdown
Contributor

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, this is really really good. I learned quite a bit from reading this PR. This is industry professional level CI, and it's well documented, clean, and very clever. You're using some nice modern features to keep things lean and dry.

Exceptional work. 🏆

Comment thread .github/workflows/build.yaml Outdated
Comment thread .github/workflows/build.yaml Outdated
Comment thread .github/workflows/deploy.yaml Outdated
Comment thread .github/workflows/deploy.yaml Outdated
Comment on lines +68 to +73
# Output linting errors in the format GitHub Actions recognises for
# annotations.
- name: Run flake8
run: >-
flake8 --format "::error
file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh, this is fancy. I like it. 👍🏼

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already do this in other projects, actually. I think I just copied it over from one if it wasn't already in the old snekbox CI.

Comment thread .github/workflows/main.yaml Outdated
Comment on lines +18 to +19
artefact: ${{ needs.build.outputs.artefact }}
tag: ${{ needs.build.outputs.tag }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

holy shit I had no idea this was legal syntax but it's so cool.

Comment thread .github/workflows/test.yaml Outdated
There isn't enough "meat" to warrant their use.
The latter is consistent with GitHub Action's documentation.
There are no pipes the in script, so the presence of -o pipefail may
confuse readers.
@MarkKoz MarkKoz merged commit e526aa8 into main Feb 13, 2022
@MarkKoz MarkKoz deleted the ci-refactor branch February 13, 2022 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: CI Related to continuous intergration and deployment type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants