From 64421dab8202bc294e3e33d4df002ed93fe9f7e7 Mon Sep 17 00:00:00 2001 From: antazoey Date: Thu, 31 Aug 2023 07:28:38 -0500 Subject: [PATCH 1/2] fix: only default to `-U` if there is not a `version` in the config [APE-1180] (#26) --- .../{test.yaml => test_ape_version.yaml} | 12 ++++-- .github/workflows/test_plugins.yaml | 39 +++++++++++++++++++ README.md | 14 ++++--- action.yml | 26 ++++++++++++- ape-config.yaml | 4 ++ mdformat.yaml | 1 + 6 files changed, 85 insertions(+), 11 deletions(-) rename .github/workflows/{test.yaml => test_ape_version.yaml} (80%) create mode 100644 .github/workflows/test_plugins.yaml create mode 100644 ape-config.yaml create mode 100644 mdformat.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test_ape_version.yaml similarity index 80% rename from .github/workflows/test.yaml rename to .github/workflows/test_ape_version.yaml index e423330..5720d14 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test_ape_version.yaml @@ -1,4 +1,4 @@ -name: tests +name: Ape Version Test on: push: @@ -9,7 +9,7 @@ on: paths-ignore: ['**.md'] concurrency: - group: ${{ github.ref }} + group: ${{ github.ref }}-version cancel-in-progress: true jobs: @@ -19,7 +19,13 @@ jobs: strategy: fail-fast: false matrix: - version: ["default", "0.6.11", "==0.6.11", "git+https://github.com/ApeWorX/ape.git@main"] + version: + [ + 'default', + '0.6.11', + '==0.6.11', + 'git+https://github.com/ApeWorX/ape.git@main', + ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/test_plugins.yaml b/.github/workflows/test_plugins.yaml new file mode 100644 index 0000000..710bac8 --- /dev/null +++ b/.github/workflows/test_plugins.yaml @@ -0,0 +1,39 @@ +name: Ape Plugins Test + +on: + push: + branches: [main] + tags-ignore: ['**'] + paths-ignore: ['**.md'] + pull_request: + paths-ignore: ['**.md'] + +concurrency: + group: ${{ github.ref }}-plugins + cancel-in-progress: true + +jobs: + run-this-action: + name: Run action (${{ matrix.plugins }}) + runs-on: [ubuntu-latest] + strategy: + fail-fast: false + matrix: + plugins: ['default', 'tokens', 'tokens==0.6.1'] + steps: + - uses: actions/checkout@v3 + + - name: Check plugins + id: check-plugins + run: | + if [[ "${{ matrix.plugins }}" != "default" ]]; then + echo "ape-plugins=${{ matrix.plugins }}" >> $GITHUB_OUTPUT + fi + + - name: Run ape action + id: ape-action + uses: ./ + with: + ape-plugins-list: ${{ steps.check-plugins.outputs.ape-plugins }} + + - run: ape plugins list diff --git a/README.md b/README.md index 9ce7031..bb00921 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,19 @@ Can also use a `git+` value to install a branch, commit, or tag. Example values: -* `1.0.0` -* `==1.0.0` -* `>=1.0.0,<2.0` -* `git+https://github.com/your-github/ape.git@your-branch` +- `1.0.0` +- `==1.0.0` +- `>=1.0.0,<2.0` +- `git+https://github.com/your-github/ape.git@your-branch` ### `ape-plugins-list` **Optional** Space-separated list of plugins to install. -Default is to install from local `ape-config.yaml`. +The default is to install from your project's local `ape-config.yaml`. +If you do not have any plugin version constraints specified in your `ape-config.yaml` file, the default includes the `-U` (`--upgrade`) flag to ensure you get the latest plugin versons. +Otherwise, it relies on the constraints you have configured. -Note: When requesting a pin, put it all together like `'plugin-a plugin-b==1.2.3 plugin-c>1.2'` +To request specific versions of plugins, use a space-separated value like this `'plugin-a plugin-b==1.2.3 plugin-c>1.2'`. ## Outputs diff --git a/action.yml b/action.yml index 58bab99..259e61c 100644 --- a/action.yml +++ b/action.yml @@ -16,7 +16,7 @@ inputs: ape-plugins-list: description: 'Space seperated list of plugins to install with relevant pinning applied' required: False - default: '-U .' + default: '' outputs: ape-version: @@ -88,7 +88,29 @@ runs: fi shell: bash - - run: ape plugins install ${{ inputs.ape-plugins-list }} + - name: Check ape-config.yaml exists + id: check-ape-config-yaml + 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) + else + version_present=0 + fi + + if [[ "${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" + shell: bash - name: Find if requirements.txt if exists diff --git a/ape-config.yaml b/ape-config.yaml new file mode 100644 index 0000000..c3d6ac3 --- /dev/null +++ b/ape-config.yaml @@ -0,0 +1,4 @@ +# This file exists only as a test for the action. +plugins: + - name: tokens + version: 0.6.1 diff --git a/mdformat.yaml b/mdformat.yaml new file mode 100644 index 0000000..01b2fb0 --- /dev/null +++ b/mdformat.yaml @@ -0,0 +1 @@ +number = true From 186f2f8fd7d9633a2b608dfbce191c70274e34d0 Mon Sep 17 00:00:00 2001 From: antazoey Date: Tue, 5 Sep 2023 09:55:15 -0500 Subject: [PATCH 2/2] fix: issue with default plugins version variable when versions in config [APE-1370] (#29) --- .github/workflows/test_ape_version.yaml | 2 +- .github/workflows/test_plugins.yaml | 16 +++++++++-- action.yml | 38 ++++++++++++++++--------- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test_ape_version.yaml b/.github/workflows/test_ape_version.yaml index 5720d14..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: diff --git a/.github/workflows/test_plugins.yaml b/.github/workflows/test_plugins.yaml index 710bac8..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: @@ -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: ./ 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