diff --git a/.github/actions/build_export_docker/action.yml b/.github/actions/build_export_docker/action.yml new file mode 100644 index 00000000..fb70fabd --- /dev/null +++ b/.github/actions/build_export_docker/action.yml @@ -0,0 +1,21 @@ +name: "Build and export docker image" +description: "Builds and exports the docker images required by Parsec CI" +inputs: + image-name: + required: true + description: "Docker image name" + +runs: + using: "composite" + steps: + - name: Build the docker container + run: pushd e2e_tests/docker_image && docker build -t ${{ inputs.image-name }} -f ${{ inputs.image-name }}.Dockerfile . && popd + shell: bash + - name: Export the docker container + run: docker save ${{ inputs.image-name }} | gzip > /tmp/${{ inputs.image-name }}.tar + shell: bash + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.image-name }} + path: /tmp/${{ inputs.image-name }}.tar diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81773466..9337843c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,30 +5,41 @@ on: pull_request: workflow_dispatch: inputs: - trigger_docker: + trigger_test_all_docker: description: "'parsec-service-test-all' if docker build should be triggered" required: false default: "" + trigger_test_cross_docker: + description: "'parsec-service-test-cross-compile' if docker build should be triggered" + required: false + default: "" env: - TEST_ALL_DOCKER_IMAGE: ${{ github.event.inputs.trigger_docker || 'ghcr.io/parallaxsecond/parsec-service-test-all' }} + TEST_ALL_DOCKER_IMAGE: ${{ github.event.inputs.trigger_test_all_docker || 'ghcr.io/parallaxsecond/parsec-service-test-all' }} + TEST_CROSS_DOCKER_IMAGE: ${{ github.event.inputs.trigger_test_cross_docker || 'ghcr.io/parallaxsecond/parsec-service-test-cross-compile' }} jobs: build-and-export-test-all-docker: runs-on: ubuntu-latest # For running this job we need to manually trigger the CI and set the variable - if: ${{ github.event.inputs.trigger_docker == 'parsec-service-test-all' }} + if: ${{ github.event.inputs.trigger_test_all_docker == 'parsec-service-test-all' }} steps: - uses: actions/checkout@v3 - - name: Build the docker container - run: pushd e2e_tests/docker_image && docker build -t parsec-service-test-all -f parsec-service-test-all.Dockerfile . && popd - - name: Export the docker container - run: docker save parsec-service-test-all > /tmp/parsec-service-test-all.tar - - name: Upload artifact - uses: actions/upload-artifact@v3 + - name: Build and Export Docker Image + uses: ./.github/actions/build_export_docker with: - name: parsec-service-test-all - path: /tmp/parsec-service-test-all.tar + image-name: "parsec-service-test-all" + + build-and-export-cross-compile-docker: + runs-on: ubuntu-latest + # For running this job we need to manually trigger the CI and set the variable + if: ${{ github.event.inputs.trigger_test_cross_docker == 'parsec-service-test-cross-compile' }} + steps: + - uses: actions/checkout@v3 + - name: Build and Export Docker Image + uses: ./.github/actions/build_export_docker + with: + image-name: "parsec-service-test-cross-compile" all-providers: name: Various tests targeting a Parsec image with all providers included @@ -165,13 +176,22 @@ jobs: # Currently only the Mbed Crypto, PKCS 11, and TPM providers are tested as the other ones need to cross-compile other libraries. name: Cross-compile Parsec to various targets runs-on: ubuntu-latest + if: ${{ always() }} + needs: [build-and-export-cross-compile-docker] steps: - - uses: actions/checkout@v2 - - name: Run the container to execute the test script - run: - docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-cross-compile /tmp/parsec/test/cross-compile.sh - # When running the container built on the CI - # run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec -t parsec-service-test-cross-compile /tmp/parsec/test/cross-compile.sh + - uses: actions/checkout@v3 + - name: Load Docker + uses: ./.github/actions/load_docker + if: ${{ env.TEST_CROSS_DOCKER_IMAGE == 'parsec-service-test-cross-compile' }} + with: + image-name: "${{ env.TEST_CROSS_DOCKER_IMAGE }}" + image-path: "/tmp" + - name: Run the cross compiler tests using pre-built docker image + if: ${{ env.TEST_CROSS_DOCKER_IMAGE != 'parsec-service-test-cross-compile' }} + run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec ghcr.io/parallaxsecond/parsec-service-test-cross-compile /tmp/parsec/test/cross-compile.sh + - name: Run the cross compiler tests using image built on the CI + if: ${{ env.TEST_CROSS_DOCKER_IMAGE == 'parsec-service-test-cross-compile' }} + run: docker run -v $(pwd):/tmp/parsec -w "${{ env.TEST_CROSS_DOCKER_IMAGE }}" /tmp/parsec/test/cross-compile.sh links: name: Check links