Skip to content

Commit

Permalink
fix: Earthly integration tests use 'earthly/dind' container | NPG-000 (
Browse files Browse the repository at this point in the history
…#537)

# Description

CI tests are breaking because Earthly tries to install docker in
containers that don't have it, causing unexpected timeouts. As
recommended by Earthly Docs,
https://docs.earthly.dev/best-practices#use-earthly-dind , this PR
updates integration tests to address this problem.


## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce.
Please also list any relevant details for your test configuration

- [x] Local execution of `earthly -P +test`

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
  • Loading branch information
saibatizoku authored Sep 27, 2023
1 parent 613385f commit 2a68afe
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,46 @@ on:
pull_request:
branches:
- main
- fix-earthly-integration-testing

permissions:
id-token: write
contents: read
packages: write

env:
AWS_REGION: eu-central-1
AWS_ROLE_ARN: arn:aws:iam::332405224602:role/ci
EARTHLY_VERSION: 0.7.6
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
TAG: ${{ github.sha }}

jobs:
build:
name: CI Test
runs-on: ubuntu-latest
env:
FORCE_COLOR: 1
steps:
- name: Setup CI
uses: input-output-hk/catalyst-ci/actions/setup@master
with:
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
aws_region: ${{ env.AWS_REGION }}
earthly_version: ${{ env.EARTHLY_VERSION }}
- name: Install Earthly
uses: earthly/actions/setup-earthly@v1
with:
version: v0.7.0
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
- name: Login to ECR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.ECR_REGISTRY }}
- name: Run tests
env:
EARTHLY_SECRETS: "IDEASCALE_EMAIL=${{ secrets.IDEASCALE_EMAIL }}, IDEASCALE_PASSWORD=${{ secrets.IDEASCALE_PASSWORD }}, IDEASCALE_API_TOKEN=${{ secrets.IDEASCALE_API_TOKEN }}"
run: |
earthly -P --remote-cache=ghcr.io/${{ github.repository }}:cache +test
earthly -P --buildkit-host "tcp://${{ secrets.EARTHLY_SATELLITE_ADDRESS }}:8372" +test
9 changes: 7 additions & 2 deletions src/cat-data-service/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ docker:

# Need to be run with the -P flag
test:
FROM ../../+builder
FROM earthly/dind:alpine

COPY ../../src/event-db+docker-compose/docker-compose.yml docker-compose.yml
WITH DOCKER \
--compose docker-compose.yml \
--pull postgres:14 \
--load migrations:latest=(../../containers/event-db-migrations+docker --data=test) \
--load test:latest=(../../+builder) \
--service migrations \
--allow-privileged
RUN EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" cargo test -p cat-data-service --all-features
RUN docker run \
--network default_default \
-e EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@postgres/CatalystEventDev" \
test:latest \
cargo test -p cat-data-service --all-features
END

9 changes: 7 additions & 2 deletions src/event-db/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ docker-compose:

# Need to be run with the -P flag
test:
FROM ../../+builder
FROM earthly/dind:alpine

COPY +docker-compose/docker-compose.yml .
WITH DOCKER \
--compose docker-compose.yml \
--pull postgres:14 \
--load migrations:latest=(../../containers/event-db-migrations+docker --data=test) \
--load test:latest=(../../+builder) \
--service migrations \
--allow-privileged
RUN EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" cargo test -p event-db
RUN docker run \
--network default_default \
-e EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@postgres/CatalystEventDev" \
test:latest \
cargo test -p event-db
END

0 comments on commit 2a68afe

Please sign in to comment.