Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with default plugins version variable when versions in config [APE-1370] #29

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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