From 0c630664b818202c436152e4d65dd0bb4cf68874 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Mon, 17 Jul 2023 10:07:05 +0100 Subject: [PATCH] Smoke test for include guard --- .github/workflows/test_include_guard.yaml | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/test_include_guard.yaml diff --git a/.github/workflows/test_include_guard.yaml b/.github/workflows/test_include_guard.yaml new file mode 100644 index 00000000..bac58e62 --- /dev/null +++ b/.github/workflows/test_include_guard.yaml @@ -0,0 +1,52 @@ +name: Test Tensorflow include guards +# These tests check that the include guards checking for tensorflow's availability +# behave as expected on ubuntu and macOS. + +on: + pull_request: + push: + branches: [main] + +jobs: + tensorflow_guards: + name: Test include guards + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install via pip + run: python -m pip install -e . + + - name: Test (working) import + uses: jannekem/run-python-script-action@v1 + with: + fail-on-error: true + script: | + import cellfinder_core + + - name: Uninstall tensorflow + run: python -m pip uninstall tensorflow + + - name: Test (broken) import + id: broken_import + uses: jannekem/run-python-script-action@v1 + with: + fail-on-error: false + script: | + import cellfinder_core + + # exit 1 will force an actions exit with a failure reported + - name: Check error was thrown by broken import + if: steps.broken_import.outputs.error == 'false' + run: | + echo "Broken import test result was: ${{ steps.broken_import.outputs.error }}" + exit 1