33 pull_request :
44
55jobs :
6- detect-changes :
6+ get-enclaves :
77 runs-on : ubuntu-24.04
88 outputs :
99 enclaves : ${{ steps.changed.outputs.enclaves }}
@@ -13,32 +13,19 @@ jobs:
1313 fetch-depth : 0
1414 - id : changed
1515 run : |
16- diff=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
17-
18- # 1. If there are changes other than the enclaves dir, execute the build for all elcs.
19- # 2. If only the enclaves dir have changed, build only the elc where the changes occurred.
20- if echo $diff | grep -v '^enclaves/' > /dev/null; then
21- enclaves=$(find enclaves -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | jq -R . | jq -s -c .)
22- else
23- enclaves=$(echo $diff \
24- | grep '^enclaves/' \
25- | awk -F'/' '$2 !~/\./ {print $2}' \
26- | sort -u \
27- | jq -R . | jq -s -c .)
28- fi
29-
16+ enclaves=$(find enclaves -maxdepth 1 -mindepth 1 -type d -printf '%f\n' | jq -R . | jq -s -c .)
3017 echo "enclaves=$enclaves" >> "$GITHUB_OUTPUT"
3118 build :
32- needs : detect-changes
33- if : needs.detect-changes .outputs.enclaves != '[]'
19+ needs : get-enclaves
20+ if : needs.get-enclaves .outputs.enclaves != '[]'
3421 runs-on : ubuntu-24.04
3522 strategy :
3623 matrix :
37- enclave : ${{ fromJson(needs.detect-changes .outputs.enclaves) }}
24+ enclave : ${{ fromJson(needs.get-enclaves .outputs.enclaves) }}
3825 network : [testnet, mainnet]
3926 permissions :
4027 contents : read # For checkout repo
41- packages : write # For Push Image to ghcr.io
28+ packages : write # For Push Image for buildCache to ghcr.io
4229 steps :
4330 - uses : actions/checkout@v4
4431 - uses : docker/setup-buildx-action@v3
@@ -53,19 +40,37 @@ jobs:
5340 with :
5441 images : ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}
5542 tags : ${{ github.event.pull_request.head.sha }}
43+ - name : Set UID and GID as env
44+ run : |
45+ echo "UID=$(id -u)" >> "$GITHUB_ENV"
46+ echo "GID=$(id -g)" >> "$GITHUB_ENV"
5647 - uses : docker/build-push-action@v5
5748 with :
5849 context : .
5950 push : false
60- load : true
6151 build-args : |
6252 LCP_ELC_TYPE=${{ matrix.enclave }}
6353 DEPLOYMENT_NETWORK=${{ matrix.network }}
54+ UID=${{ env.UID }}
55+ GID=${{ env.GID }}
6456 tags : ${{ steps.meta.outputs.tags }}
6557 labels : ${{ steps.meta.outputs.labels }}
6658 cache-from : type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}:buildCache
6759 cache-to : type=registry,ref=ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}:buildCache,mode=max
68- - name : Output MRENCLAVE
60+ outputs : type=docker # save the image locally
61+ - name : Test
6962 run : |
70- docker run --rm -t ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}:${{ github.event.pull_request.head.sha }} \
71- bash -c "/app/scripts/mrenclave.sh /out /tests/mrenclave > mrenclave.log 2>&1 && cat /tests/mrenclave/mrenclave.txt || { cat mrenclave.log; exit 1; }"
63+ # Check whether the MRENCLAVE calculated locally when updating the enclave and
64+ # the MRENCLAVE derived from the Image created in the test case are the same value.
65+
66+ mkdir -p tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}
67+ docker run --rm -v $(pwd)/tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}:/app/tests/mrenclave \
68+ ghcr.io/${{ github.repository }}/${{ matrix.enclave }}/${{ matrix.network }}:${{ github.event.pull_request.head.sha }} \
69+ bash -c "/app/scripts/mrenclave.sh /out /app/tests/mrenclave > mrenclave.log 2>&1 || { cat mrenclave.log; exit 1; }"
70+
71+ echo "Local:$(cat enclaves/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE)"
72+ echo "Test: $(cat tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE)"
73+
74+ diff \
75+ enclaves/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE \
76+ tests/${{ matrix.enclave }}/mrenclaves/${{ matrix.network }}/MRENCLAVE
0 commit comments