diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5bac0501..4fbe75e9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,10 +1,11 @@ -name: Publish to TestPyPI +name: Publish to PyPI -on: push - -#on: -# release: -# types: [published] +on: + push: + # Only try to publish if it's tagged + tags: + - 'v*' + - 'testpypi-v*' jobs: build: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4ebcfb6..6265931e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,33 +159,37 @@ jobs: send-summary-comment: true show-annotations: "warning" - test-against-ofm: + test-against-ofm-v3: runs-on: ubuntu-latest continue-on-error: true defaults: run: - working-directory: /home/runner/work/openflexure-microscope-server/ - steps: + working-directory: ../openflexure-microscope-server/ + env: + REF: v3 + steps: &test-against-ofm-steps - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: - python-version: 3.11 + python-version: '3.11' - - name: Install OpenFlexure Microscope Server - working-directory: /home/runner/work/ + - name: Clone OpenFlexure Microscope Server + working-directory: .. # This step creates the default working directory run: | git clone https://gitlab.com/openflexure/openflexure-microscope-server.git - cd openflexure-microscope-server - git checkout v3 - pip install -e .[dev] + + - name: Check out OpenFlexure Microscope Server + run: "git checkout $REF" + + - name: Install OpenFlexure Microscope Server + run: "pip install -e ../openflexure-microscope-server/[dev]" - name: Install LabThings-FastAPI - run: pip install -e ../labthings-fastapi/labthings-fastapi/ + run: "pip install -e ../labthings-fastapi" - name: Print installed packages - run: pip freeze + run: "pip freeze" - name: Configure Git identity run: | @@ -206,3 +210,41 @@ jobs: - name: Type check with `mypy` run: mypy src + + check-for-ofm-feature-branch: + # This job runs only if a feature branch is specified in the merge request description. + # The line below looks for a line starting with `OFM Feature Branch:`. This should + # match the `grep` command in the step script. + if: contains(toJson(github.event.pull_request.body), '\r\nOFM Feature Branch:') + runs-on: ubuntu-latest + outputs: + feature-branch: ${{ steps.determine-feature-branch.outputs.feature-branch}} + steps: + - name: Determine feature branch + env: + PULL_REQUEST_BODY: ${{ github.event.pull_request.body }} + # The `if:` block for this job has already checked we will have a matching line. + # The logic below will first extract the matching line from the PR description, + # then remove the prefix so we're left with only the branch name, which we check + # out. + run: | + matching_line=$(echo "$PULL_REQUEST_BODY" | grep "^OFM Feature Branch:") + feature_branch="${matching_line##"OFM Feature Branch: "}" + echo "Using feature branch '$feature_branch'" + echo "feature-branch=$feature_branch" >> "$GITHUB_OUTPUT" + id: determine-feature-branch + + test-against-ofm-feature-branch: + # This job uses the feature branch found by the previous job. + # It is split from that job in order to allow re-use of the steps from + # test-against-ofm-v3 + needs: check-for-ofm-feature-branch + runs-on: ubuntu-latest + continue-on-error: true + defaults: + run: + working-directory: ../openflexure-microscope-server/ + env: + REF: ${{ needs.check-for-ofm-feature-branch.outputs.feature-branch }} + steps: *test-against-ofm-steps +