Skip to content

init

init #101

Workflow file for this run

name: Test
on:
pull_request:
jobs:
get-enclaves:
runs-on: ubuntu-24.04
outputs:
enclaves: ${{ steps.changed.outputs.enclaves }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: changed
run: |
enclaves=$(find enclaves -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | jq -R . | jq -s -c .)
echo "enclaves=$enclaves" >> "$GITHUB_OUTPUT"
build:
needs: get-enclaves
if: needs.get-enclaves.outputs.enclaves != '[]'
runs-on: ubuntu-24.04
strategy:
matrix:
enclave: ${{ fromJson(needs.get-enclaves.outputs.enclaves) }}
network: [testnet, mainnet]
permissions:
contents: read # For checkout repo
packages: write # For Push Image for buildCache to ghcr.io
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
logout: true
- id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}
tags: ${{ github.event.pull_request.head.sha }}
- name: Set UID and GID as env
run: |
echo "UID=$(id -u)" >> "$GITHUB_ENV"
echo "GID=$(id -g)" >> "$GITHUB_ENV"
- uses: docker/build-push-action@v5
with:
context: .
push: false
build-args: |
LCP_ELC_TYPE=${{ matrix.enclave }}
DEPLOYMENT_NETWORK=${{ matrix.network }}
UID=${{ env.UID }}
GID=${{ env.GID }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}:buildCache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}:buildCache,mode=max
outputs: type=docker # save the image locally
- name: Test
run: |
# Check whether the MRENCLAVE calculated locally when updating the enclave and
# the MRENCLAVE derived from the Image created in the test case are the same value.
mkdir -p tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}
docker run --rm -v $(pwd)/tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}:/app/tests/mrenclave \
ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}:${{ github.event.pull_request.head.sha }} \
bash -c "/app/scripts/mrenclave.sh /out /app/tests/mrenclave > mrenclave.log 2>&1 || { cat mrenclave.log; exit 1; }"
echo "Local:$(cat enclaves/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE)"
echo "Test: $(cat tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE)"
diff \
enclaves/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE \
tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE