Skip to content

Commit

Permalink
introduce a install-conjure action (#205)
Browse files Browse the repository at this point in the history
* and again!

* CI: make install-conjure an action

* CI: Another hyphen typo

* Another hypen!

* Fix typo, the path does not update until the next action is run, so we cant check if this worked

* a

* lets try this

* some debugging

* more testing

* Found it!

* b
  • Loading branch information
niklasdewally authored Feb 9, 2024
1 parent 07e2d8d commit c841010
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 55 deletions.
41 changes: 41 additions & 0 deletions .github/actions/install-conjure/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Install Conjure'
description: 'Install Conjure'
inputs:
version:
description: 'The version of conjure to install.'
required: false
default: "2.5.1"
os_arch:
description: 'The OS / Architecture to use. Supported values are ["linux","macos-arm","macos-intel"]'
required: true

runs:
using: composite
steps:
- run: |
if [ "$(conjure --version | head -n2 | tail -n1)" == "Release version ${{ inputs.version }}" ]; then
echo "Found conjure, not fetching again."
else
mkdir -p "${HOME}/conjure"
cd "${HOME}/conjure"
echo "Downloading conjure."
rm -rf conjure-v${{ inputs.version }}-${{ inputs.os_arch }}-with-solvers*
wget https://github.com/conjure-cp/conjure/releases/download/v${{ inputs.version }}/conjure-v${{ inputs.version }}-${{ inputs.os_arch }}-with-solvers.zip
unzip conjure-v${{ inputs.version }}-${{ inputs.os_arch }}-with-solvers.zip
echo "Adding conjure to path."
# this prepends to path (so imagemagick doesnt interfere!), and does not take effect until the next step runs.
echo "${HOME}/conjure/conjure-v${{ inputs.version }}-${{ inputs.os_arch }}-with-solvers/" >> ${GITHUB_PATH}
fi
shell: bash
- name: Check that conjure is installed correctly
run: |
if [ "$(conjure --version | head -n2 | tail -n1)" != "Release version ${{ inputs.version }}" ]; then
echo "Correct conjure not found in path."
conjure --version
exit 1
fi
shell: bash

23 changes: 4 additions & 19 deletions .github/workflows/code-coverage-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:

env:
rust_release: nightly
conjure_version:
- 2.5.1
release_suffix: linux

jobs:
coverage:
Expand Down Expand Up @@ -39,22 +36,10 @@ jobs:
working-directory: ./solvers/minion
run: rustup update ${{ env.rust_release }} && rustup default ${{ env.rust_release }}

- name: Add conjure to PATH
run: echo "${HOME}/.cargo/bin/conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers" >> ${GITHUB_PATH}

- name: Install conjure
run: |
if [ "$(conjure --version | head -n2 | tail -n1)" == "Release version ${{ env.conjure_version }}" ]; then
echo "Found conjure, not fetching again."
else
echo "Did not find conjure, fetching."
pushd ~/.cargo/bin
rm -rf conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers*
wget https://github.com/conjure-cp/conjure/releases/download/v${{ env.conjure_version }}/conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers.zip
unzip conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers.zip
popd
fi
conjure --version
- uses: ./.github/actions/install-conjure
with:
os_arch: linux
version: 2.5.1

- name: Generate coverage reports
working-directory: .
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ name: "Code Coverage (Generate)"
on:
pull_request:
paths:
- conjure-oxide/**
- conjure_oxide/**
- solvers/**
- crates/**
- .github/actions/code-coverage.yml
workflow_dispatch:

env:
rust_release: nightly
conjure_version:
- 2.5.1
release_suffix: linux

jobs:
coverage:
Expand Down Expand Up @@ -58,19 +55,10 @@ jobs:
- name: Add conjure to PATH
run: echo "${HOME}/.cargo/bin/conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers" >> ${GITHUB_PATH}

- name: Install conjure
run: |
if [ "$(conjure --version | head -n2 | tail -n1)" == "Release version ${{ env.conjure_version }}" ]; then
echo "Found conjure, not fetching again."
else
echo "Did not find conjure, fetching."
pushd ~/.cargo/bin
rm -rf conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers*
wget https://github.com/conjure-cp/conjure/releases/download/v${{ env.conjure_version }}/conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers.zip
unzip conjure-v${{ env.conjure_version }}-${{ env.release_suffix }}-with-solvers.zip
popd
fi
conjure --version
- uses: ./.github/actions/install-conjure
with:
os_arch: linux
version: 2.5.1

- name: Generate coverage reports
working-directory: .
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/doc-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
branches:
- main # run for pushes to the main branch
paths:
- conjure-oxide/**
- conjure_oxide/**
- solvers/**
- crates/**
- .github/actions/doc-coverage.yml
pull_request:
paths:
- conjure-oxide/**
- conjure_oxide/**
- solvers/**
- crates/**
- .github/actions/doc-coverage.yml
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,11 @@ jobs:

- run: cargo build -vv --workspace

- name: Add conjure to PATH
run: echo "${HOME}/.cargo/bin/conjure-v${{ matrix.conjure_version }}-${{ matrix.release_suffix }}-with-solvers" >> ${GITHUB_PATH}

- name: Install conjure
run: |
if [ "$(conjure --version | head -n2 | tail -n1)" == "Release version ${{ matrix.conjure_version }}" ]; then
echo "Found conjure, not fetching again."
else
echo "Did not find conjure, fetching."
pushd ~/.cargo/bin
rm -rf conjure-v${{ matrix.conjure_version }}-${{ matrix.release_suffix }}-with-solvers*
wget https://github.com/conjure-cp/conjure/releases/download/v${{ matrix.conjure_version }}/conjure-v${{ matrix.conjure_version }}-${{ matrix.release_suffix }}-with-solvers.zip
unzip conjure-v${{ matrix.conjure_version }}-${{ matrix.release_suffix }}-with-solvers.zip
popd
fi
conjure --version
- uses: ./.github/actions/install-conjure
with:
os_arch: ${{ matrix.release_suffix }}
version: ${{ matrix.conjure_version }}

- run: cargo test --workspace

audit:
Expand Down

0 comments on commit c841010

Please sign in to comment.