Skip to content

Commit

Permalink
Merge pull request #78 from ConorMacBride/libraries-to-template
Browse files Browse the repository at this point in the history
Move libraries installation to separate template
  • Loading branch information
ConorMacBride committed Dec 8, 2021
2 parents 476a6e3 + 66b4ef6 commit 19dd8d2
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 23 deletions.
12 changes: 12 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ stages:
- linux: testtoxargs
toxargs: --notest

- template: run-tox-env.yml
parameters:
libraries:
apt:
- rolldice
envs:
- linux: global_libraries
- linux: env_libraries
libraries:
apt:
- bcal

- template: run-tox-env.yml
parameters:
cache_dirs:
Expand Down
37 changes: 37 additions & 0 deletions install-libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
parameters:
- name: 'libraries'
type: object
default: {}
- name: 'env_key'
type: string
default: ''
- name: 'docker_name'
type: string
default: ''
- name: 'setarch'
type: string
default: ''

steps:
- ${{ each tool_pair in parameters.libraries }}:
- ${{ each library in tool_pair.value }}:

- ${{ if and(eq(tool_pair.key, 'brew'), eq(parameters.env_key, 'macos')) }}:
- script: brew install ${{ library }}
displayName: Installing ${{ library }} with brew

- ${{ if and(eq(tool_pair.key, 'brew-cask'), eq(parameters.env_key, 'macos')) }}:
- script: brew cask install ${{ library }}
displayName: Installing ${{ library }} with brew cask

- ${{ if and(eq(tool_pair.key, 'apt'), eq(parameters.env_key, 'linux')) }}:
- script: sudo apt-get install -y ${{ library }}
displayName: Installing ${{ library }} with apt

- ${{ if and(eq(tool_pair.key, 'yum'), or(eq(parameters.env_key, 'linux32'), eq(parameters.env_key, 'manylinux'))) }}:
- script: docker exec -i -w /project ${{ parameters.docker_name }} ${{ parameters.setarch }} yum install -y ${{ library }}
displayName: Installing ${{ library }} with yum

- ${{ if and(eq(tool_pair.key, 'choco'), eq(parameters.env_key, 'windows')) }}:
- script: choco install ${{ library }}
displayName: Installing ${{ library }} with choco
36 changes: 14 additions & 22 deletions run-tox-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,20 @@ jobs:
inputs: ${{ cache }}
displayName: Processing cache at ${{ cache['path'] }}

- ${{ each tool_pair in coalesce(env['libraries'], parameters.libraries) }}:
- ${{ each library in tool_pair.value }}:

- ${{ if and(eq(tool_pair.key, 'brew'), eq(env_pair.key, 'macos')) }}:
- script: brew install ${{ library }}
displayName: Installing ${{ library }} with brew

- ${{ if and(eq(tool_pair.key, 'brew-cask'), eq(env_pair.key, 'macos')) }}:
- script: brew cask install ${{ library }}
displayName: Installing ${{ library }} with brew cask

- ${{ if and(eq(tool_pair.key, 'apt'), eq(env_pair.key, 'linux')) }}:
- script: sudo apt-get install -y ${{ library }}
displayName: Installing ${{ library }} with apt

- ${{ if and(eq(tool_pair.key, 'yum'), or(eq(env_pair.key, 'linux32'), eq(env_pair.key, 'manylinux'))) }}:
- script: docker exec -i -w /project ${{ variables.docker_name }} ${{ variables.setarch }} yum install -y ${{ library }}
displayName: Installing ${{ library }} with yum

- ${{ if and(eq(tool_pair.key, 'choco'), eq(env_pair.key, 'windows')) }}:
- script: choco install ${{ library }}
displayName: Installing ${{ library }} with choco
- ${{ if env['libraries'] }}:
- template: install-libraries.yml
parameters:
libraries: ${{ env['libraries'] }}
env_key: ${{ env_pair.key }}
docker_name: ${{ variables.docker_name }}
setarch: ${{ variables.setarch }}
- ${{ elseif parameters.libraries }}:
- template: install-libraries.yml
parameters:
libraries: ${{ parameters.libraries }}
env_key: ${{ env_pair.key }}
docker_name: ${{ variables.docker_name }}
setarch: ${{ variables.setarch }}

- ${{ if not(variables.docker_image) }}:
- task: UsePythonVersion@0
Expand Down
17 changes: 16 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ envlist =
testtoxargs
cache-a
cache-b
cache-c
global_libraries
env_libraries

requires = pip >= 18.0
setuptools >= 30.3.0
Expand All @@ -37,3 +38,17 @@ commands:

[testenv:testtoxargs]
commands = "/bin/bash exit 1;"

[testenv:global_libraries]
whitelist_externals = /usr/bin/bash
deps =
commands =
bash -c "which rolldice && exit 0 || exit 1"
bash -c "which bcal && exit 1 || exit 0"

[testenv:env_libraries]
whitelist_externals = /usr/bin/bash
deps =
commands =
bash -c "which rolldice && exit 1 || exit 0"
bash -c "which bcal && exit 0 || exit 1"

0 comments on commit 19dd8d2

Please sign in to comment.