|
| 1 | +name: STSAFE-A120 simulator test |
| 2 | + |
| 3 | +# START OF COMMON SECTION |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [ 'master', 'main', 'release/**' ] |
| 7 | + pull_request: |
| 8 | + branches: [ '*' ] |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | +# END OF COMMON SECTION |
| 14 | + |
| 15 | +# Build the STSAFE-A120 software simulator (https://github.com/wolfSSL/simulators, |
| 16 | +# STSAFEA120Sim/ subdirectory), build wolfSSL against STMicro's STSELib + |
| 17 | +# simulator bridge, and run the wolfCrypt STSAFE-A120 test binary against the |
| 18 | +# simulator TCP server. |
| 19 | +# |
| 20 | +# The simulator's own Dockerfile (Dockerfile.wolfcrypt) clones wolfSSL master |
| 21 | +# and applies two sed patches to it. Both patches are now upstreamed in |
| 22 | +# wolfSSL itself (the include.am stsafe.c entry, and the |
| 23 | +# stse_platform_generic.h include order in stsafe.c), so we: |
| 24 | +# 1. COPY the PR checkout instead of cloning master. |
| 25 | +# 2. Strip the now-redundant sed RUN block. |
| 26 | +# 3. Switch the configure invocation from a raw -DWOLFSSL_STSAFEA120 |
| 27 | +# CFLAG to the new --enable-stsafe=a120 option. |
| 28 | + |
| 29 | +env: |
| 30 | + SIMULATORS_REF: 7e4a50ac3316680c523ec2f66711ea8403c94468 |
| 31 | + |
| 32 | +jobs: |
| 33 | + stsafe_a120_sim: |
| 34 | + name: wolfCrypt against STSAFE-A120 simulator |
| 35 | + if: github.repository_owner == 'wolfssl' |
| 36 | + runs-on: ubuntu-24.04 |
| 37 | + timeout-minutes: 30 |
| 38 | + steps: |
| 39 | + - name: Checkout wolfSSL (PR source) |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + path: wolfssl-src |
| 43 | + |
| 44 | + - name: Clone STSAFE-A120 simulator |
| 45 | + run: | |
| 46 | + git clone https://github.com/wolfSSL/simulators simulators |
| 47 | + cd simulators && git checkout "$SIMULATORS_REF" |
| 48 | +
|
| 49 | + - name: Stage PR wolfSSL into simulator build context |
| 50 | + run: mv wolfssl-src simulators/STSAFEA120Sim/wolfssl |
| 51 | + |
| 52 | + - name: Patch Dockerfile to use PR wolfSSL and the upstreamed STSAFE build flags |
| 53 | + working-directory: simulators/STSAFEA120Sim |
| 54 | + run: | |
| 55 | + # 1. Replace the upstream master clone with a COPY of the PR source. |
| 56 | + sed -i 's|^RUN git clone --branch \${WOLFSSL_REF} --depth 1 \\$|COPY wolfssl /app/wolfssl|' Dockerfile.wolfcrypt |
| 57 | + # The COPY directive above is one line, so drop the now-stranded |
| 58 | + # `https://github.com/wolfSSL/wolfssl.git /app/wolfssl` continuation |
| 59 | + # line that followed the original `git clone --depth 1 \` line. |
| 60 | + sed -i '\|^ https://github.com/wolfSSL/wolfssl.git /app/wolfssl$|d' Dockerfile.wolfcrypt |
| 61 | + # Fail fast if the pattern drifted upstream -- better a clear error |
| 62 | + # than a CI run that silently tests master. |
| 63 | + grep -q '^COPY wolfssl /app/wolfssl$' Dockerfile.wolfcrypt |
| 64 | + ! grep -q 'git clone .*wolfssl\.git' Dockerfile.wolfcrypt |
| 65 | +
|
| 66 | + # 2. Neutralise the sed-patch RUN block: the patches it applies |
| 67 | + # (adding stsafe.c to include.am, prepending |
| 68 | + # stse_platform_generic.h to stsafe.c) are now upstream and |
| 69 | + # rerunning them would produce duplicate entries. |
| 70 | + sed -i '/^RUN sed -i \\$/,/^ head -2 \/app\/wolfssl\/wolfcrypt\/src\/port\/st\/stsafe\.c$/c\RUN true' Dockerfile.wolfcrypt |
| 71 | + ! grep -q 'sed -i .*include.am' Dockerfile.wolfcrypt |
| 72 | + ! grep -q 'sed -i .*port/st/stsafe.c' Dockerfile.wolfcrypt |
| 73 | +
|
| 74 | + # 3. Switch the wolfSSL configure invocation to the new |
| 75 | + # --enable-stsafe=a120 option, and drop the now-redundant raw |
| 76 | + # -DWOLFSSL_STSAFEA120 from CFLAGS. |
| 77 | + sed -i 's|^ --disable-examples \\$| --disable-examples \\\n --enable-stsafe=a120 \\|' Dockerfile.wolfcrypt |
| 78 | + sed -i 's|-DWOLFSSL_STSAFEA120 ||' Dockerfile.wolfcrypt |
| 79 | + grep -q -- '--enable-stsafe=a120' Dockerfile.wolfcrypt |
| 80 | + ! grep -q -- '-DWOLFSSL_STSAFEA120' Dockerfile.wolfcrypt |
| 81 | +
|
| 82 | + - uses: docker/setup-buildx-action@v3 |
| 83 | + |
| 84 | + - name: Build wolfCrypt-STSAFE-A120 test image |
| 85 | + uses: docker/build-push-action@v5 |
| 86 | + with: |
| 87 | + context: simulators/STSAFEA120Sim |
| 88 | + file: simulators/STSAFEA120Sim/Dockerfile.wolfcrypt |
| 89 | + push: false |
| 90 | + load: true |
| 91 | + tags: wolfssl-stsafe-a120-sim:ci |
| 92 | + cache-from: type=gha |
| 93 | + cache-to: type=gha,mode=max |
| 94 | + |
| 95 | + - name: Run wolfCrypt tests against simulator |
| 96 | + run: docker run --rm wolfssl-stsafe-a120-sim:ci |
0 commit comments