feat: implement new cache system for Docker #100
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration test - API | |
on: pull_request | |
jobs: | |
build_and_cache: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Build Docker Image | |
run: docker build -t block-explorer_app:latest | |
- name: Cache Docker Image | |
uses: actions/cache@v2 | |
with: | |
path: | | |
/var/lib/docker | |
key: docker-image-${{ runner.os }}-${{ hashFiles('**/*.dockerfile') }} | |
if: success() | |
use_cached_docker_image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Restore Cached Docker Image | |
uses: actions/cache@v2 | |
with: | |
path: | | |
/var/lib/docker | |
key: docker-image-${{ runner.os }}-${{ hashFiles('**/*.dockerfile') }} | |
#- name: Use Docker Image in Another Job | |
# run: | | |
# # Your commands to use the Docker image | |
runTests: | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
checks: write | |
strategy: | |
matrix: | |
node-version: ['lts/*'] # 18.17.1 or lts/* | |
test-pattern: | |
#- accounts.test.ts | |
#- addresses.test.ts | |
#- batches.test.ts | |
#- blocks.test.ts | |
#- contracts.test.ts | |
#- logs.test.ts | |
#- stats.test.ts | |
#- tokens.test.ts | |
- transactions.test.ts | |
name: 'API test set: ${{ matrix.test-pattern}} / Node: ${{ matrix.node-version}}' | |
steps: | |
- name: Checkout with Submodule | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# - name: Cache Docker images | |
# id: cache-docker-images | |
# uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ~/.docker | |
# key: ${{ runner.os }}-docker-${{ hashFiles('**/docker-compose.yaml') }} | |
# restore-keys: | | |
# ${{ runner.os }}-docker- | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: npm | |
- name: Install dependencies | |
run: | | |
npm ci --no-audit | |
npx playwright install --with-deps chromium | |
#- name: Start docker containers | |
# run: | | |
# docker-compose -f "docker-compose.yaml" up -d --build | |
- name: List running containers | |
run: docker ps | |
- name: API tests run (parallel) | |
run: | | |
cd packages/integration-tests | |
npx jest --verbose --testPathPattern=${{ matrix.test-pattern }} | |
- name: Stop containers | |
if: always() | |
run: | | |
docker-compose -f "docker-compose.yaml" down |