Skip to content

Commit

Permalink
Remove independent build and cache job
Browse files Browse the repository at this point in the history
Our caching strategy is to cached across CI jobs with the focus on
caching the layers in the Docker image.

As each job has to build the image from (using the cache) regardless, we
think we can get rid of the independent build and cache job and let the
caching happen as we run each job.

The only way to see if this pays off is to merge the changes and run
another CI workflow to see how much caching we get.

We have also split each linter and formatter into their own `run` steps,
this is for clarity.
  • Loading branch information
mec committed Nov 18, 2024
1 parent f4b9263 commit ca62b83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ runs:
load: true
tags: app_test:latest
cache-from: type=gha
cache-to: type=gha,mode=min
44 changes: 14 additions & 30 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,9 @@ on:
- develop

jobs:
build-and-cache:
name: Build and cache image
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and cache image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
build-args: RAILS_ENV=test
push: false
tags: app_test:latest
cache-from: type=gha
cache-to: type=gha,mode=min

lint-and-format:
name: Lint and format application
runs-on: ubuntu-latest
needs: build-and-cache
steps:
-
name: Checkout
Expand All @@ -44,17 +21,25 @@ jobs:
name: Load cache
uses: ./.github/actions/continuous-integration/load-cache
-
name: Run linters and formatters
name: Run Ruby standard
run: |
docker run --rm app_test:latest /bin/bash -c "bundle exec standardrb -f simple"
-
name: Run ESLint
run: |
docker run --rm app_test:latest /bin/bash -c "yarn run lint:js"
-
name: Run Stylelint
run: |
docker run --rm app_test:latest /bin/bash -c "yarn run lint:css"
-
name: Run Prettier
run: |
docker run --rm app_test:latest /bin/bash -c "bundle exec standardrb -f simple && \
yarn run lint:js && \
yarn run lint:css && \
yarn run lint:format"
docker run --rm app_test:latest /bin/bash -c "yarn run lint:format"
static-analysis:
name: Static analysis
runs-on: ubuntu-latest
needs: build-and-cache
steps:
-
name: Checkout
Expand All @@ -70,7 +55,6 @@ jobs:
specs:
name: Specs and coverage
runs-on: ubuntu-latest
needs: build-and-cache
steps:
-
name: Checkout
Expand Down

0 comments on commit ca62b83

Please sign in to comment.