Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add caching to CI operations #1696

Merged
merged 31 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a033885
Add basic caching
jonastheis Sep 17, 2021
b768a9b
Fix syntax
jonastheis Sep 17, 2021
65aea38
Fix syntax
jonastheis Sep 17, 2021
4e7c722
Load built image to docker images
jonastheis Sep 17, 2021
459e280
This is a blank commit
jonastheis Sep 17, 2021
7df9239
Cache Go build and dependencies
jonastheis Sep 17, 2021
7a23e71
Fix Go caching path and add temporary move fix for Docker layer caching
jonastheis Sep 17, 2021
50263ed
Try to build tester with docker compose before
jonastheis Sep 17, 2021
3b10101
Use cache for unit tests
jonastheis Sep 17, 2021
933ec7d
Move caching for unit tests after repo checkout
jonastheis Sep 17, 2021
d5c593a
Remove Go cache from integration tests
jonastheis Sep 20, 2021
0a1c6b2
Always run unit tests; do not use cached results from previous runs w…
jonastheis Sep 21, 2021
5619f76
Always run unit tests; do not use cached results from previous runs w…
jonastheis Sep 21, 2021
853ff15
Add no cache Docker build for comparison
jonastheis Sep 21, 2021
2a8dbbb
Test code change
jonastheis Sep 21, 2021
5c3d7ba
Use cache in mode=min
jonastheis Sep 21, 2021
9d27313
Run integration tests with Go modules cached
jonastheis Sep 21, 2021
c388a58
Do not use buildx action
jonastheis Sep 21, 2021
1d5f9d8
Change mount path
jonastheis Sep 21, 2021
3a378f3
Run container with current user
jonastheis Sep 21, 2021
6aee8ca
Update docker compose
jonastheis Sep 21, 2021
4658c6c
Echo user
jonastheis Sep 21, 2021
29dd737
Set permissions of files in bind mount
jonastheis Sep 22, 2021
9271fe4
Clean up
jonastheis Sep 22, 2021
3a3db8b
Add Go build cache for local integration test runs. Avoid caching of …
jonastheis Sep 22, 2021
6752a60
Use unique cache identifier to fall back to cache instead of getting …
jonastheis Sep 22, 2021
794ce61
Update cache keys
jonastheis Sep 22, 2021
9a640e2
Adjust cache key
jonastheis Sep 22, 2021
ba49133
Enable autopeering integration test
jonastheis Sep 22, 2021
a61bdb1
Enable caching for all integration tests
jonastheis Sep 22, 2021
26d58e4
Remove prints
jonastheis Sep 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 141 additions & 36 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,32 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
run: |
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Pull additional Docker images
run: |
docker pull angelocapossele/drand:v1.1.4
docker pull gaiaadm/pumba:0.7.2
docker pull gaiadocker/iproute2:latest

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand All @@ -44,7 +59,6 @@ jobs:
name: ${{ env.TEST_NAME }}
path: tools/integration-tests/logs


common:
name: common
env:
Expand All @@ -55,16 +69,27 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Pull additional Docker images
- name: Build GoShimmer image
run: |
docker pull angelocapossele/drand:v1.1.4
docker pull gaiadocker/iproute2:latest
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand All @@ -88,16 +113,31 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
run: |
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Pull additional Docker images
run: |
docker pull angelocapossele/drand:v1.1.4
docker pull gaiadocker/iproute2:latest

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand All @@ -122,16 +162,31 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
run: |
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Pull additional Docker images
run: |
docker pull angelocapossele/drand:v1.1.4
docker pull gaiadocker/iproute2:latest

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand All @@ -156,16 +211,27 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Pull additional Docker images
- name: Build GoShimmer image
run: |
docker pull angelocapossele/drand:v1.1.4
docker pull gaiadocker/iproute2:latest
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand All @@ -189,16 +255,27 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Pull additional Docker images
- name: Build GoShimmer image
run: |
docker pull angelocapossele/drand:v1.1.4
docker pull gaiadocker/iproute2:latest
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand All @@ -212,6 +289,7 @@ jobs:
name: ${{ env.TEST_NAME }}
path: tools/integration-tests/logs


mana:
name: mana
env:
Expand All @@ -222,16 +300,27 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Pull additional Docker images
- name: Build GoShimmer image
run: |
docker pull angelocapossele/drand:1.1.3
docker pull gaiadocker/iproute2:latest
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand All @@ -255,11 +344,27 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- name: Cache Go modules for tester container
uses: actions/cache@v2
with:
path: |
~/go
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-it-go-${{ hashFiles('tools/integration-tests/tester/go.sum') }}-
${{ runner.os }}-it-go-

- name: Build GoShimmer image
run: docker build --build-arg DOWNLOAD_SNAPSHOT=0 -t iotaledger/goshimmer .
run: |
docker build \
--build-arg DOWNLOAD_SNAPSHOT=0 \
-t iotaledger/goshimmer .

- name: Run integration tests
run: docker-compose -f tools/integration-tests/tester/docker-compose.yml up --abort-on-container-exit --exit-code-from tester --build
run: |
export CURRENT_UID=$(id -u):$(id -g)
docker-compose -f tools/integration-tests/tester/docker-compose.ci.yml up --abort-on-container-exit --exit-code-from tester

- name: Create logs from tester
if: always()
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Cache Go build and dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
# make sure concurrent runs (not really supported) do not match the same key but instead fall back to a reasonable cache
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}-${{ github.event.action }}${{ github.event.after }}
restore-keys: |
${{ runner.os }}-go-${{ hashFiles('go.sum') }}
${{ runner.os }}-go-

- name: Run Tests
run: go test ./... -tags rocksdb
run: go test ./... -tags rocksdb -count=1
8 changes: 7 additions & 1 deletion tools/integration-tests/assets/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ chmod 777 /assets/*
echo "assets:"
ls /assets
echo "running tests..."
go test ./tests/"${TEST_NAME}" -v -timeout 30m
go test ./tests/"${TEST_NAME}" -v -timeout 10m -count=1

# if running in CI we need to set right permissions on the Go folder (within container) so that it can be exported to cache
if [ ! -z ${CURRENT_UID} ]; then
echo "setting permissions on Go folder to '${CURRENT_UID}'..."
chown -R "${CURRENT_UID}" /go /root/.cache/go-build
fi
23 changes: 23 additions & 0 deletions tools/integration-tests/tester/docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3.5"

services:
tester:
container_name: tester
image: golang@sha256:cefedeae41e0bbbfa20bb1c37c3a43e0001fa541be9732f7bc6a28ecc154e9e4
working_dir: /tmp/goshimmer/tools/integration-tests/tester
command: /tmp/assets/entrypoint.sh
environment:
- TEST_NAME=${TEST_NAME}
- CURRENT_UID
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ../../..:/tmp/goshimmer:rw
- ../logs:/tmp/logs
- ../assets:/tmp/assets
- ~/go/pkg:/go
- ~/go/cache:/root/.cache/go-build
- goshimmer-testing-assets:/assets

volumes:
goshimmer-testing-assets:
name: goshimmer-testing-assets
11 changes: 7 additions & 4 deletions tools/integration-tests/tester/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.5"
services:
tester:
container_name: tester
image: golang:1.16.2
image: golang@sha256:cefedeae41e0bbbfa20bb1c37c3a43e0001fa541be9732f7bc6a28ecc154e9e4
working_dir: /tmp/goshimmer/tools/integration-tests/tester
command: /tmp/assets/entrypoint.sh
environment:
Expand All @@ -13,11 +13,14 @@ services:
- ../../..:/tmp/goshimmer:rw
- ../logs:/tmp/logs
- ../assets:/tmp/assets
- goshimmer-testing-cache:/go
- goshimmer-testing-package-cache:/go
- goshimmer-testing-build-cache:/root/.cache/go-build
- goshimmer-testing-assets:/assets

volumes:
goshimmer-testing-cache:
name: goshimmer-testing-cache
goshimmer-testing-package-cache:
name: goshimmer-testing-package-cache
goshimmer-testing-build-cache:
name: goshimmer-testing-build-cache
goshimmer-testing-assets:
name: goshimmer-testing-assets