Skip to content

Commit

Permalink
[CI] build worker and client in separate jobs (#1492)
Browse files Browse the repository at this point in the history
* [CI] build worker and client in separate jobs

* fixes
  • Loading branch information
clangenb authored Nov 15, 2023
1 parent 7a4e28f commit ea0042f
Showing 1 changed file with 77 additions and 18 deletions.
95 changes: 77 additions & 18 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,37 +86,21 @@ jobs:
--build-arg WORKER_MODE_ARG=${{ matrix.mode }} --build-arg FINGERPRINT=${FINGERPRINT} --build-arg ADDITIONAL_FEATURES_ARG=${{ matrix.additional_features }} --build-arg SGX_MODE=${{ matrix.sgx_mode }}
-f build.Dockerfile .
- name: Build CLI client
env:
DOCKER_BUILDKIT: 1
run: >
docker build -t integritee-cli-client-${{ env.IMAGE_SUFFIX }}
--target deployed-client
--build-arg WORKER_MODE_ARG=${{ matrix.mode }} --build-arg ADDITIONAL_FEATURES_ARG=${{ matrix.additional_features }}
-f build.Dockerfile .
- run: docker images --all

- name: Test Enclave # cargo test is not supported in the enclave, see: https://github.com/apache/incubator-teaclave-sgx-sdk/issues/232
run: docker run --rm ${{ env.DOCKER_DEVICES }} ${{ env.DOCKER_VOLUMES }} integritee-worker-${{ env.IMAGE_SUFFIX }} test --all

- name: Export worker image(s)
- name: Export worker image
run: |
docker image save integritee-worker-${{ env.IMAGE_SUFFIX }} | gzip > integritee-worker-${{ env.IMAGE_SUFFIX }}.tar.gz
docker image save integritee-cli-client-${{ env.IMAGE_SUFFIX }} | gzip > integritee-cli-client-${{ env.IMAGE_SUFFIX }}.tar.gz
- name: Upload worker image
uses: actions/upload-artifact@v3
with:
name: integritee-worker-${{ env.IMAGE_SUFFIX }}.tar.gz
path: integritee-worker-${{ env.IMAGE_SUFFIX }}.tar.gz

- name: Upload CLI client image
uses: actions/upload-artifact@v3
with:
name: integritee-cli-client-${{ env.IMAGE_SUFFIX }}.tar.gz
path: integritee-cli-client-${{ env.IMAGE_SUFFIX }}.tar.gz

- name: Create Enclave Digest File
run: |
mrenclave_hex=$(docker run integritee-worker-${{ env.IMAGE_SUFFIX }} mrenclave | grep -oP ':\s*\K[a-fA-F0-9]+')
Expand All @@ -133,6 +117,81 @@ jobs:
if [[ "$(docker images -q integritee-worker-${{ env.IMAGE_SUFFIX }} 2> /dev/null)" != "" ]]; then
docker image rmi --force integritee-worker-${{ env.IMAGE_SUFFIX }} 2>/dev/null
fi
docker images --all
build-client:
runs-on: ${{ matrix.host }}
strategy:
fail-fast: false
matrix:
include:
- flavor_id: sidechain
mode: sidechain
host: integritee-builder-sgx
sgx_mode: HW
additional_features: dcap
- flavor_id: offchain-worker
mode: offchain-worker
host: integritee-builder-sgx
sgx_mode: HW
additional_features: dcap
- flavor_id: teeracle
mode: teeracle
host: integritee-builder-sgx
sgx_mode: HW
additional_features: dcap
- flavor_id: sidechain-evm
mode: sidechain
additional_features: evm,dcap
host: integritee-builder-sgx
sgx_mode: HW

steps:
- uses: actions/checkout@v3

- name: Set env
run: |
fingerprint=$RANDOM
echo "FINGERPRINT=$fingerprint" >> $GITHUB_ENV
SGX_MODE_LOWERCASE=$(echo "${${{ matrix.sgx_mode }},,}")
echo "IMAGE_SUFFIX=$SGX_MODE_LOWERCASE-${{ matrix.flavor_id }}-${{ github.sha }}" >> $GITHUB_ENV
if [[ ${{ matrix.sgx_mode }} == 'HW' ]]; then
echo "DOCKER_DEVICES=--device=/dev/sgx/enclave --device=/dev/sgx/provision" >> $GITHUB_ENV
echo "DOCKER_VOLUMES=--volume /var/run/aesmd:/var/run/aesmd --volume /etc/sgx_default_qcnl.conf:/etc/sgx_default_qcnl.conf" >> $GITHUB_ENV
else
echo "DOCKER_DEVICES=" >> $GITHUB_ENV
echo "DOCKER_VOLUMES=" >> $GITHUB_ENV
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
driver: docker-container

- name: Build CLI client
env:
DOCKER_BUILDKIT: 1
run: >
docker build -t integritee-cli-client-${{ env.IMAGE_SUFFIX }}
--target deployed-client
--build-arg WORKER_MODE_ARG=${{ matrix.mode }} --build-arg ADDITIONAL_FEATURES_ARG=${{ matrix.additional_features }}
-f build.Dockerfile .
- run: docker images --all

- name: Export client image
run: |
docker image save integritee-cli-client-${{ env.IMAGE_SUFFIX }} | gzip > integritee-cli-client-${{ env.IMAGE_SUFFIX }}.tar.gz
- name: Upload CLI client image
uses: actions/upload-artifact@v3
with:
name: integritee-cli-client-${{ env.IMAGE_SUFFIX }}.tar.gz
path: integritee-cli-client-${{ env.IMAGE_SUFFIX }}.tar.gz

- name: Delete images
run: |
if [[ "$(docker images -q integritee-cli-client-${{ env.IMAGE_SUFFIX }} 2> /dev/null)" != "" ]]; then
docker image rmi --force integritee-cli-client-${{ env.IMAGE_SUFFIX }} 2>/dev/null
fi
Expand Down Expand Up @@ -198,7 +257,7 @@ jobs:
integration-tests:
runs-on: ${{ matrix.host }}
if: ${{ always() }}
needs: build-test
needs: [build-test, build-client]
env:
WORKER_IMAGE_TAG: integritee-worker:dev
CLIENT_IMAGE_TAG: integritee-cli:dev
Expand Down

2 comments on commit ea0042f

@brenzi
Copy link
Collaborator

@brenzi brenzi commented on ea0042f Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor remark: I would've preferred using cli only instead of client to avoid ambiguities.

@clangenb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh, yes. makes sense, but we are not consistent yet, it is also client in the make file still.

Please sign in to comment.