Skip to content

Commit

Permalink
fix: false feature inputs with auto-config: true (#111)
Browse files Browse the repository at this point in the history
Previously, feature inputs only overrode auto configuration when set to
true.
Fix logic in config.sh so feature inputs set to false also override auto
configuration.

Closes #110
  • Loading branch information
austinletson authored Nov 23, 2024
1 parent 5ccf7ae commit 465529c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
39 changes: 38 additions & 1 deletion .github/functional_tests/auto_config_true/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ description: |
Run `lean-action` with `auto-config: true` and no feature inputs
on a package generated with `lake init` and a dummy test runner added.
Verify `lake build` and `lake test` run successfully.
Run `lean-action` with `auto-config:true` and false feature inputs.
Verify `lake build` and `lake test` did not run.
inputs:
toolchain:
description: 'Toolchain to use for the test'
Expand Down Expand Up @@ -46,7 +49,7 @@ runs:
} >> lakefile.lean
shell: bash

- name: "run `lean-action` with `lake test`"
- name: "run `lean-action` with auto-config: true"
id: lean-action
uses: ./
with:
Expand Down Expand Up @@ -84,3 +87,37 @@ runs:
ACTUAL_VALUE: ${{ steps.lean-action.outputs.lint-status }}
run: .github/functional_tests/test_helpers/verify_action_output.sh
shell: bash


- name: "run `lean-action` with auto-config: true and false feature inputs"
id: lean-action-false-feature-inputs
uses: ./
with:
auto-config: true
build: false
test: false
lint: false
use-github-cache: false
- name: verify `lake build` did not run
env:
OUTPUT_NAME: "build-status"
EXPECTED_VALUE: ""
ACTUAL_VALUE: ${{ steps.lean-action-false-feature-inputs.outputs.build-status }}
run: .github/functional_tests/test_helpers/verify_action_output.sh
shell: bash

- name: verify `lake test` did not run
env:
OUTPUT_NAME: "test-status"
EXPECTED_VALUE: ""
ACTUAL_VALUE: ${{ steps.lean-action-false-feature-inputs.outputs.test-status }}
run: .github/functional_tests/test_helpers/verify_action_output.sh
shell: bash

- name: verify `lake lint` did not run
env:
OUTPUT_NAME: "lint-status"
EXPECTED_VALUE: ""
ACTUAL_VALUE: ${{ steps.lean-action-false-feature-inputs.outputs.lint-status }}
run: .github/functional_tests/test_helpers/verify_action_output.sh
shell: bash
30 changes: 22 additions & 8 deletions scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,35 @@ if [ "$LINT" = "true" ]; then
fi

if [ "$AUTO_CONFIG" = "true" ]; then
# always run `lake build` with `auto-config: true`
echo "auto-config: true"
echo " -> will run lake build"
run_lake_build="true"
if [ "$BUILD" = "false" ]; then
# If the user specifies `build: false`, then do not run `lake build`.
echo "build: false -> will not run lake build"
run_lake_build="false"
else
# `build` input is not `false` and `auto-config: true`
echo "auto-config: true"
echo " -> will run lake build"
run_lake_build="true"
fi

# only run `lake test` with `auto-config: true` if `lake check-test` returns true
if lake check-test; then
if [ "$TEST" = "false" ]; then
# If the user specifies `test: false`, then do not run `lake test`.
echo "test: false -> will not run lake test"
run_lake_test="false"
elif lake check-test; then
# only run `lake test` with `auto-config: true` if `lake check-test` returns true
echo "lake check-test succeeded -> will run lake test"
run_lake_test="true"
else
echo "lake check-test failed -> will not run lake test"
fi

# only run `lake lint` with `auto-config: true` if `lake check-lint` returns true
if lake check-lint; then
if [ "$LINT" = "false" ]; then
# If the user specifies `lint: false`, then do not run `lake lint`.
echo "lint: false -> will not run lake lint"
run_lake_lint="false"
elif lake check-lint; then
# only run `lake lint` with `auto-config: true` if `lake check-lint` returns true
echo "lake check-lint succeeded -> will run lake lint"
run_lake_lint="true"
else
Expand Down

0 comments on commit 465529c

Please sign in to comment.