|
| 1 | +name: 'Lake Lint Args' |
| 2 | +description: 'Run `lean-action` on with `lint-args` input' |
| 3 | +inputs: |
| 4 | + toolchain: |
| 5 | + description: 'Toolchain to use for the test' |
| 6 | + required: true |
| 7 | +runs: |
| 8 | + using: 'composite' |
| 9 | + steps: |
| 10 | + # TODO: once `lean-action` supports just setup, use it here |
| 11 | + - name: install elan |
| 12 | + run: | |
| 13 | + set -o pipefail |
| 14 | + curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain ${{ inputs.toolchain }} |
| 15 | + echo "$HOME/.elan/bin" >> "$GITHUB_PATH" |
| 16 | + shell: bash |
| 17 | + |
| 18 | + - name: create lake package with `lake init ${{ inputs.lake-init-arguments }}` |
| 19 | + run: | |
| 20 | + lake init lintargs .lean |
| 21 | + lake update |
| 22 | + shell: bash |
| 23 | + |
| 24 | + - name: create lint script template |
| 25 | + run: | |
| 26 | + cp lakefile.lean lint_script.template |
| 27 | + cat <<'TEMPLATE' >> lint_script.template |
| 28 | + @[lint_driver] |
| 29 | + script check_lint_args (args) do |
| 30 | + let expected := @EXPECTED_ARGS@ |
| 31 | + if args == expected then |
| 32 | + IO.println s!"✓ Arguments match expected: {expected}" |
| 33 | + return 0 |
| 34 | + else |
| 35 | + IO.eprintln s!"✗ Arguments mismatch!" |
| 36 | + IO.eprintln s!" Expected: {expected}" |
| 37 | + IO.eprintln s!" Got: {args}" |
| 38 | + return 1 |
| 39 | + TEMPLATE |
| 40 | + shell: bash |
| 41 | + |
| 42 | + - name: configure script for single driver argument test |
| 43 | + run: | |
| 44 | + sed 's/@EXPECTED_ARGS@/["test-arg"]/' lint_script.template > lakefile.lean |
| 45 | + shell: bash |
| 46 | + |
| 47 | + - name: "run `lean-action` with single lint-arg passed to driver" |
| 48 | + id: lean-action-single |
| 49 | + uses: ./ |
| 50 | + with: |
| 51 | + lint: true |
| 52 | + lint-args: "-- test-arg" |
| 53 | + use-github-cache: false |
| 54 | + |
| 55 | + - name: verify `lean-action` outcome success |
| 56 | + env: |
| 57 | + OUTPUT_NAME: "lean-action-single.outcome" |
| 58 | + EXPECTED_VALUE: "success" |
| 59 | + ACTUAL_VALUE: ${{ steps.lean-action-single.outcome }} |
| 60 | + run: .github/functional_tests/test_helpers/verify_action_output.sh |
| 61 | + shell: bash |
| 62 | + |
| 63 | + - name: verify single argument was passed correctly |
| 64 | + env: |
| 65 | + OUTPUT_NAME: "lint-status (single arg)" |
| 66 | + EXPECTED_VALUE: "SUCCESS" |
| 67 | + ACTUAL_VALUE: ${{ steps.lean-action-single.outputs.lint-status }} |
| 68 | + run: .github/functional_tests/test_helpers/verify_action_output.sh |
| 69 | + shell: bash |
| 70 | + |
| 71 | + - name: lake clean |
| 72 | + run: lake clean |
| 73 | + shell: bash |
| 74 | + |
| 75 | + - name: configure script for multiple driver arguments test |
| 76 | + run: | |
| 77 | + sed 's/@EXPECTED_ARGS@/["arg1", "arg2", "arg3"]/' lint_script.template > lakefile.lean |
| 78 | + shell: bash |
| 79 | + |
| 80 | + - name: "run `lean-action` with multiple lint args passed to driver" |
| 81 | + id: lean-action-multiple |
| 82 | + uses: ./ |
| 83 | + with: |
| 84 | + lint: true |
| 85 | + lint-args: "-- arg1 arg2 arg3" |
| 86 | + use-github-cache: false |
| 87 | + |
| 88 | + - name: verify `lean-action-multiple` outcome success |
| 89 | + env: |
| 90 | + OUTPUT_NAME: "lean-action-multiple.outcome" |
| 91 | + EXPECTED_VALUE: "success" |
| 92 | + ACTUAL_VALUE: ${{ steps.lean-action-multiple.outcome }} |
| 93 | + run: .github/functional_tests/test_helpers/verify_action_output.sh |
| 94 | + shell: bash |
| 95 | + |
| 96 | + - name: verify multiple arguments were passed correctly |
| 97 | + env: |
| 98 | + OUTPUT_NAME: "lint-status (multiple args)" |
| 99 | + EXPECTED_VALUE: "SUCCESS" |
| 100 | + ACTUAL_VALUE: ${{ steps.lean-action-multiple.outputs.lint-status }} |
| 101 | + run: .github/functional_tests/test_helpers/verify_action_output.sh |
| 102 | + shell: bash |
| 103 | + |
| 104 | + - name: lake clean |
| 105 | + run: lake clean |
| 106 | + shell: bash |
| 107 | + |
| 108 | + - name: configure script for empty args test (lake flags) |
| 109 | + run: | |
| 110 | + sed 's/@EXPECTED_ARGS@/([] : List String)/' lint_script.template > lakefile.lean |
| 111 | + shell: bash |
| 112 | + |
| 113 | + - name: "run `lean-action` with lake flags (not driver args)" |
| 114 | + id: lean-action-flags |
| 115 | + uses: ./ |
| 116 | + with: |
| 117 | + lint: true |
| 118 | + lint-args: "--quiet" |
| 119 | + use-github-cache: false |
| 120 | + |
| 121 | + - name: verify `lean-action-flags` outcome success |
| 122 | + env: |
| 123 | + OUTPUT_NAME: "lean-action-flags.outcome" |
| 124 | + EXPECTED_VALUE: "success" |
| 125 | + ACTUAL_VALUE: ${{ steps.lean-action-flags.outcome }} |
| 126 | + run: .github/functional_tests/test_helpers/verify_action_output.sh |
| 127 | + shell: bash |
| 128 | + |
| 129 | + - name: verify lake flag was passed correctly |
| 130 | + env: |
| 131 | + OUTPUT_NAME: "lint-status (lake flags)" |
| 132 | + EXPECTED_VALUE: "SUCCESS" |
| 133 | + ACTUAL_VALUE: ${{ steps.lean-action-flags.outputs.lint-status }} |
| 134 | + run: .github/functional_tests/test_helpers/verify_action_output.sh |
| 135 | + shell: bash |
0 commit comments