From 5f983b810c0f78a040982c3919dfcf6f478e9334 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Tue, 5 Sep 2023 07:47:12 -0500 Subject: [PATCH 1/2] test: add test --- .github/workflows/test_ape_version.yaml | 3 +++ .github/workflows/test_plugins.yaml | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_ape_version.yaml b/.github/workflows/test_ape_version.yaml index 5720d14..3777490 100644 --- a/.github/workflows/test_ape_version.yaml +++ b/.github/workflows/test_ape_version.yaml @@ -26,6 +26,8 @@ jobs: '==0.6.11', 'git+https://github.com/ApeWorX/ape.git@main', ] + plugins: ['config_with_version'] + steps: - uses: actions/checkout@v3 @@ -37,6 +39,7 @@ jobs: else echo "ape-version=${{ matrix.version }}" >> $GITHUB_OUTPUT fi + - name: Run ape action id: ape-action uses: ./ diff --git a/.github/workflows/test_plugins.yaml b/.github/workflows/test_plugins.yaml index 710bac8..fbc4b73 100644 --- a/.github/workflows/test_plugins.yaml +++ b/.github/workflows/test_plugins.yaml @@ -19,15 +19,23 @@ 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 + elif [[ "${{ 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 From 13d39b4c254833a08f24810cf9c8f54ba5e18c18 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Tue, 5 Sep 2023 08:03:11 -0500 Subject: [PATCH 2/2] fix: interop bug --- .github/workflows/test_ape_version.yaml | 5 +--- .github/workflows/test_plugins.yaml | 10 ++++--- action.yml | 38 ++++++++++++++++--------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test_ape_version.yaml b/.github/workflows/test_ape_version.yaml index 3777490..e4fc532 100644 --- a/.github/workflows/test_ape_version.yaml +++ b/.github/workflows/test_ape_version.yaml @@ -1,4 +1,4 @@ -name: Ape Version Test +name: Version Test on: push: @@ -26,8 +26,6 @@ jobs: '==0.6.11', 'git+https://github.com/ApeWorX/ape.git@main', ] - plugins: ['config_with_version'] - steps: - uses: actions/checkout@v3 @@ -39,7 +37,6 @@ jobs: else echo "ape-version=${{ matrix.version }}" >> $GITHUB_OUTPUT fi - - name: Run ape action id: ape-action uses: ./ diff --git a/.github/workflows/test_plugins.yaml b/.github/workflows/test_plugins.yaml index fbc4b73..d64bda7 100644 --- a/.github/workflows/test_plugins.yaml +++ b/.github/workflows/test_plugins.yaml @@ -1,4 +1,4 @@ -name: Ape Plugins Test +name: Plugins Test on: push: @@ -21,7 +21,7 @@ jobs: matrix: plugins: [ 'default_with_version_config', - 'default_without_version_in_config' + 'default_without_version_in_config', 'tokens', 'tokens==0.6.1' ] @@ -31,9 +31,11 @@ jobs: - name: Check plugins id: check-plugins run: | - if [[ "${{ matrix.plugins }}" != *"default_"* ]]; then + if [[ "${{ matrix.plugins }}" != default_* ]]; then echo "ape-plugins=${{ matrix.plugins }}" >> $GITHUB_OUTPUT - elif [[ "${{ matrix.plugins }}" == "default_without_version_in_config" ]]; then + 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 diff --git a/action.yml b/action.yml index 259e61c..2a0ce04 100644 --- a/action.yml +++ b/action.yml @@ -93,15 +93,25 @@ 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 ." @@ -109,17 +119,17 @@ runs: 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