Skip to content

Commit 2a68afe

Browse files
authored
fix: Earthly integration tests use 'earthly/dind' container | NPG-000 (#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
1 parent 613385f commit 2a68afe

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

.github/workflows/ci-test.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,46 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- fix-earthly-integration-testing
78

89
permissions:
910
id-token: write
1011
contents: read
1112
packages: write
1213

14+
env:
15+
AWS_REGION: eu-central-1
16+
AWS_ROLE_ARN: arn:aws:iam::332405224602:role/ci
17+
EARTHLY_VERSION: 0.7.6
18+
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
19+
TAG: ${{ github.sha }}
20+
1321
jobs:
1422
build:
1523
name: CI Test
1624
runs-on: ubuntu-latest
1725
env:
1826
FORCE_COLOR: 1
1927
steps:
28+
- name: Setup CI
29+
uses: input-output-hk/catalyst-ci/actions/setup@master
30+
with:
31+
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
32+
aws_region: ${{ env.AWS_REGION }}
33+
earthly_version: ${{ env.EARTHLY_VERSION }}
2034
- name: Install Earthly
2135
uses: earthly/actions/setup-earthly@v1
2236
with:
2337
version: v0.7.0
2438
- uses: actions/checkout@v2
2539
with:
2640
fetch-depth: 0
27-
- name: Login to GitHub Container Registry
41+
- name: Login to ECR
2842
uses: docker/login-action@v2
2943
with:
30-
registry: ghcr.io
31-
username: ${{ github.actor }}
32-
password: ${{ secrets.GITHUB_TOKEN }}
44+
registry: ${{ env.ECR_REGISTRY }}
3345
- name: Run tests
3446
env:
3547
EARTHLY_SECRETS: "IDEASCALE_EMAIL=${{ secrets.IDEASCALE_EMAIL }}, IDEASCALE_PASSWORD=${{ secrets.IDEASCALE_PASSWORD }}, IDEASCALE_API_TOKEN=${{ secrets.IDEASCALE_API_TOKEN }}"
3648
run: |
37-
earthly -P --remote-cache=ghcr.io/${{ github.repository }}:cache +test
49+
earthly -P --buildkit-host "tcp://${{ secrets.EARTHLY_SATELLITE_ADDRESS }}:8372" +test

src/cat-data-service/Earthfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ docker:
2424

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

2929
COPY ../../src/event-db+docker-compose/docker-compose.yml docker-compose.yml
3030
WITH DOCKER \
3131
--compose docker-compose.yml \
3232
--pull postgres:14 \
3333
--load migrations:latest=(../../containers/event-db-migrations+docker --data=test) \
34+
--load test:latest=(../../+builder) \
3435
--service migrations \
3536
--allow-privileged
36-
RUN EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" cargo test -p cat-data-service --all-features
37+
RUN docker run \
38+
--network default_default \
39+
-e EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@postgres/CatalystEventDev" \
40+
test:latest \
41+
cargo test -p cat-data-service --all-features
3742
END
3843

src/event-db/Earthfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@ docker-compose:
3838

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

4343
COPY +docker-compose/docker-compose.yml .
4444
WITH DOCKER \
4545
--compose docker-compose.yml \
4646
--pull postgres:14 \
4747
--load migrations:latest=(../../containers/event-db-migrations+docker --data=test) \
48+
--load test:latest=(../../+builder) \
4849
--service migrations \
4950
--allow-privileged
50-
RUN EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev" cargo test -p event-db
51+
RUN docker run \
52+
--network default_default \
53+
-e EVENT_DB_URL="postgres://catalyst-event-dev:CHANGE_ME@postgres/CatalystEventDev" \
54+
test:latest \
55+
cargo test -p event-db
5156
END

0 commit comments

Comments
 (0)