Run unit tests #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run unit tests | |
| on: | |
| workflow_run: | |
| workflows: | |
| - "Generate golang constants" | |
| branches: | |
| - main | |
| types: | |
| - completed # ensure the generation of constants is finished before running tests | |
| workflow_dispatch: | |
| inputs: | |
| unicorn_ref: | |
| description: "Unicorn ref (branch, tag ou commit hash) — overrides matrix" | |
| required: false | |
| default: "" | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| unicorn_ref: | |
| - latest_tag | |
| - dev | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: stable | |
| - name: Resolve unicorn ref | |
| id: resolve | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| OVERRIDE="${{ github.event.inputs.unicorn_ref }}" | |
| if [ -n "$OVERRIDE" ]; then | |
| echo "ref=$OVERRIDE" >> $GITHUB_OUTPUT | |
| elif [ "${{ matrix.unicorn_ref }}" = "latest_tag" ]; then | |
| TAG=$(curl -sf https://api.github.com/repos/unicorn-engine/unicorn/releases/latest | jq -r '.tag_name') | |
| echo "ref=$TAG" >> $GITHUB_OUTPUT | |
| else | |
| echo "ref=dev" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Clone unicorn | |
| run: | | |
| git clone \ | |
| --depth 1 \ | |
| --branch ${{ steps.resolve.outputs.ref }} \ | |
| https://github.com/unicorn-engine/unicorn \ | |
| unicorn | |
| - name: Build & install unicorn | |
| run: | | |
| cd unicorn | |
| mkdir build && cd build | |
| cmake .. -DCMAKE_BUILD_TYPE=Release | |
| make -j$(nproc) | |
| sudo make install | |
| sudo ldconfig | |
| - name: Run tests | |
| run: go test -v . | |
| env: | |
| CGO_CFLAGS: "-I${{ github.workspace }}/unicorn/include" | |
| CGO_LDFLAGS: "-L${{ github.workspace }}/unicorn/build -lunicorn" |