Update main.yml #12
This file contains hidden or 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: IDP Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
idp-tests: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 10 | |
# Setup Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 # Use your project's Node.js version | |
cache: 'pnpm' | |
# Install dependencies | |
- name: Install dependencies | |
run: pnpm install | |
# Cache test data | |
- name: Cache test data | |
uses: actions/cache@v3 | |
with: | |
path: | | |
test/data/roundtrips | |
test/data/idp.data | |
key: ${{ runner.os }}-test-data-${{ hashFiles('test/data/idp.data/.git') }}-${{ hashFiles('test/docker-compose.yml') }} | |
restore-keys: | | |
${{ runner.os }}-test-data- | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
# Cache Docker layers | |
- name: Restore Docker layers | |
id: cache-docker-layers-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-docker-${{ hashFiles('test/docker-compose.yml') }} | |
# Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Create docker-compose-cache.json | |
- name: Create docker-compose-cache.json | |
run: | | |
echo '{ | |
"target": { | |
"xsugar": { | |
"cache-from": [ | |
"type=local,src=/tmp/.buildx-cache" | |
], | |
"cache-to": [ | |
"type=local,dest=/tmp/.buildx-cache" | |
], | |
"output": [ | |
"type=docker" | |
] | |
} | |
} | |
}' > /tmp/docker-compose-cache.json | |
# Pre-build the Docker image | |
- name: Pre-build xsugar Docker image | |
run: | | |
docker buildx bake --file test/docker-compose.yml --file /tmp/docker-compose-cache.json | |
env: | |
DOCKER_BUILDKIT: 1 | |
# Cache Docker layers | |
- name: Restore Docker layers | |
id: cache-docker-layers-save | |
uses: actions/cache/save@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ steps.cache-docker-layers-restore.outputs.cache-primary-key }} | |
# Run tests | |
- name: Run IDP tests | |
run: pnpm test:idp | |
env: | |
DOCKER_BUILDKIT: 1 | |
- name: Cleanup | |
run: pnpm test:idp:xsugar:down |