Skip to content

Commit

Permalink
fix: issue with default plugins version variable when versions in con…
Browse files Browse the repository at this point in the history
…fig [APE-1370] (#29)
  • Loading branch information
antazoey committed Sep 5, 2023
1 parent 64421da commit 186f2f8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_ape_version.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ape Version Test
name: Version Test

on:
push:
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/test_plugins.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ape Plugins Test
name: Plugins Test

on:
push:
Expand All @@ -19,17 +19,27 @@ jobs:
strategy:
fail-fast: false
matrix:
plugins: ['default', 'tokens', 'tokens==0.6.1']
plugins: [
'default_with_version_config',
'default_without_version_in_config',
'tokens',
'tokens==0.6.1'
]
steps:
- uses: actions/checkout@v3

- name: Check plugins
id: check-plugins
run: |
if [[ "${{ matrix.plugins }}" != "default" ]]; then
if [[ "${{ matrix.plugins }}" != default_* ]]; then
echo "ape-plugins=${{ matrix.plugins }}" >> $GITHUB_OUTPUT
fi
if [[ "${{ matrix.plugins }}" == "default_without_version_in_config" ]]; then
# Remove the version so it defaults to `. -U`.
sed -i 's/version: 0.6.1//g' "ape-config.yaml"
fi
- name: Run ape action
id: ape-action
uses: ./
Expand Down
38 changes: 24 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,33 +93,43 @@ runs:
uses: andstor/file-existence-action@v2
with:
files: 'ape-config.yaml'

- run: |
if [[ "${{ steps.check-ape-config-yaml.outputs.files_exists }}" == "true" ]]; then
version_present=$(sed -n '/^plugins:/,/^[^ ]/{/version:/p;}' "ape-config.yaml" | grep -c version)

- name: Check version specs in config
id: check-plugin-version-specs
run: |
if [[ "${{ steps.check-ape-config-yaml.outputs.files_exists }}" == "true" ]]; then
version_present=$(sed -n '/^plugins:/,/^[^ ]/{/version:/p;}' "ape-config.yaml" | grep -c version || true)
if [[ -z "${version_present}" ]]; then
echo "version_present=0" >> $GITHUB_OUTPUT
else
echo "version_present=1" >> $GITHUB_OUTPUT
fi
else
version_present=0
echo "version_present=0" >> $GITHUB_OUTPUT
fi
shell: bash

if [[ "${version_present}" == "1" ]] && [[ -z "${{ inputs.ape-plugins-list }}" ]]; then
- name: Install Plugins
run: |
if [[ "${{ steps.check-plugin-version-specs.outputs.version_present }}" == "1" ]] && [[ -z "${{ inputs.ape-plugins-list }}" ]]; then
plugins_value="."
elif [[ -z "${{ inputs.ape-plugins-list }}" ]]; then
plugins_value="--upgrade ."
else
plugins_value="${{ inputs.ape-plugins-list }}"
fi
ape plugins install "$plugins_value"
ape plugins install $plugins_value
shell: bash

- name: Find if requirements.txt if exists
id: find-requirements-txt
run: |
echo "file=$(ls requirements.txt)" >> $GITHUB_OUTPUT
shell: bash

- name: Check requirments.txt exists
id: check-requirements-txt
uses: andstor/file-existence-action@v2
with:
files: 'requirements.txt'
- name: Install requirements.txt
run: pip install -r requirements.txt
shell: bash
if: steps.find-requirements-txt.outputs.file == 'requirements.txt'
if: steps.check-ape-config-yaml.outputs.files_exists == true

0 comments on commit 186f2f8

Please sign in to comment.