├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── dependabot.yml ├── functional_tests │ ├── auto_config_false │ │ └── action.yml │ ├── auto_config_true │ │ └── action.yml │ ├── lake_build_args │ │ └── action.yml │ ├── lake_check_test_failure │ │ └── action.yml │ ├── lake_init_failure │ │ └── action.yml │ ├── lake_init_success │ │ └── action.yml │ ├── lake_lint_failure │ │ └── action.yml │ ├── lake_lint_success │ │ └── action.yml │ ├── lake_test_failure │ │ └── action.yml │ ├── lake_test_success │ │ └── action.yml │ ├── mathlib_dependency │ │ └── action.yml │ ├── reinstall-transient-toolchain │ │ └── action.yml │ ├── subdirectory_lake_package │ │ └── action.yml │ └── test_helpers │ │ └── verify_action_output.sh ├── issue_templates │ └── release_template.md └── workflows │ ├── actionlint.yml │ ├── functional_tests.yml │ └── shellcheck.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASING.md ├── action.yml └── scripts ├── check_reservoir_eligibility.sh ├── config.sh ├── detect_mathlib.sh ├── install_elan.sh ├── lake_build.sh ├── lake_lint.sh ├── lake_test.sh ├── run_lean4checker.sh ├── set_output_parameters.sh └── step_summaries └── lake_check_error.md /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | Describe the unexpected behavior 12 | 13 | **Expected behavior** 14 | Describe the expected behavior 15 | 16 | **Link to workflow where bug was encountered:** [link] 17 | 18 | **Details** 19 | - `lean-action` version: [e.g. v1] 20 | - GitHub runner: [e.g. `ubuntu-latest`, `macos-latest`, `windows-latest`] 21 | 22 | **Additional context** 23 | Add any other context about the problem here. 24 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # See the documentation for all configuration options: 2 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 3 | 4 | version: 2 5 | updates: 6 | - package-ecosystem: "github-actions" # See documentation for possible values 7 | directory: "/" # Location of package manifests 8 | schedule: 9 | interval: "daily" 10 | -------------------------------------------------------------------------------- /.github/functional_tests/auto_config_false/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Auto Config False Functional Test' 2 | description: | 3 | Run `lean-action` with `auto-config: false` and no feature inputs. 4 | Verify that build and test steps do not run. 5 | Run `lean-action` with `auto-config: false` and `lean4checker: true`. 6 | Verify that build and tests steps do not run and action succeeds. 7 | inputs: 8 | toolchain: 9 | description: 'Toolchain to use for the test' 10 | required: true 11 | runs: 12 | using: 'composite' 13 | steps: 14 | # TODO: once `lean-action` supports just setup, use it here 15 | - name: install elan 16 | run: | 17 | set -o pipefail 18 | curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain ${{ inputs.toolchain }} 19 | echo "$HOME/.elan/bin" >> "$GITHUB_PATH" 20 | shell: bash 21 | 22 | - name: create lake package 23 | run: | 24 | lake init autoconfigtest .lean 25 | lake update 26 | shell: bash 27 | 28 | - name: "run `lean-action` with `auto-config: false`" 29 | id: lean-action 30 | uses: ./ 31 | with: 32 | auto-config: false 33 | use-github-cache: false 34 | 35 | - name: verify `lean-action` outcome success 36 | env: 37 | OUTPUT_NAME: "lean-action.outcome" 38 | EXPECTED_VALUE: "success" 39 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 40 | run: .github/functional_tests/test_helpers/verify_action_output.sh 41 | shell: bash 42 | 43 | - name: verify `lake build` not run 44 | env: 45 | OUTPUT_NAME: "build-status" 46 | EXPECTED_VALUE: "" 47 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 48 | run: .github/functional_tests/test_helpers/verify_action_output.sh 49 | shell: bash 50 | 51 | - name: verify `lake test` not run 52 | env: 53 | OUTPUT_NAME: "test-status" 54 | EXPECTED_VALUE: "" 55 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 56 | run: .github/functional_tests/test_helpers/verify_action_output.sh 57 | shell: bash 58 | 59 | - name: verify `lake lint` not run 60 | env: 61 | OUTPUT_NAME: "lint-status" 62 | EXPECTED_VALUE: "" 63 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 64 | run: .github/functional_tests/test_helpers/verify_action_output.sh 65 | shell: bash 66 | 67 | - name: "run `lean-action` with `auto-config: false` and `lean4checker: true`" 68 | id: lean-action-lean4checker 69 | uses: ./ 70 | with: 71 | auto-config: false 72 | build: true 73 | lean4checker: true 74 | use-github-cache: false 75 | 76 | - name: verify `lean-action` outcome success 77 | env: 78 | OUTPUT_NAME: "lean-action.outcome" 79 | EXPECTED_VALUE: "success" 80 | ACTUAL_VALUE: ${{ steps.lean-action-lean4checker.outcome }} 81 | run: .github/functional_tests/test_helpers/verify_action_output.sh 82 | shell: bash 83 | 84 | - name: verify `lake build` ran 85 | env: 86 | OUTPUT_NAME: "build-status" 87 | EXPECTED_VALUE: "SUCCESS" 88 | ACTUAL_VALUE: ${{ steps.lean-action-lean4checker.outputs.build-status }} 89 | run: .github/functional_tests/test_helpers/verify_action_output.sh 90 | shell: bash 91 | 92 | - name: verify `lake test` not run 93 | env: 94 | OUTPUT_NAME: "test-status" 95 | EXPECTED_VALUE: "" 96 | ACTUAL_VALUE: ${{ steps.lean-action-lean4checker.outputs.test-status }} 97 | run: .github/functional_tests/test_helpers/verify_action_output.sh 98 | shell: bash 99 | 100 | - name: verify `lake lint` not run 101 | env: 102 | OUTPUT_NAME: "lint-status" 103 | EXPECTED_VALUE: "" 104 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 105 | run: .github/functional_tests/test_helpers/verify_action_output.sh 106 | shell: bash 107 | -------------------------------------------------------------------------------- /.github/functional_tests/auto_config_true/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Auto Config True Functional Test' 2 | description: | 3 | Run `lean-action` with `auto-config: true` and no feature inputs 4 | on a package generated with `lake init` and a dummy test runner added. 5 | Verify `lake build` and `lake test` run successfully. 6 | 7 | Run `lean-action` with `auto-config:true` and false feature inputs. 8 | Verify `lake build` and `lake test` did not run. 9 | inputs: 10 | toolchain: 11 | description: 'Toolchain to use for the test' 12 | required: true 13 | runs: 14 | using: 'composite' 15 | steps: 16 | # TODO: once `lean-action` supports just setup, use it here 17 | - name: install elan 18 | run: | 19 | set -o pipefail 20 | curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain ${{ inputs.toolchain }} 21 | echo "$HOME/.elan/bin" >> "$GITHUB_PATH" 22 | shell: bash 23 | 24 | - name: create lake package 25 | run: | 26 | lake init autoconfigtest .lean 27 | lake update 28 | shell: bash 29 | 30 | - name: create successful dummy test 31 | run: | 32 | { 33 | echo "@[test_runner]" 34 | echo "script dummy_test do" 35 | echo " println! \"Running fake tests...\"" 36 | echo " println! \"Fake tests passed!\"" 37 | echo " return 0" 38 | } >> lakefile.lean 39 | shell: bash 40 | 41 | - name: create successful dummy lint 42 | run: | 43 | { 44 | echo "@[lint_driver]" 45 | echo "script dummy_lint do" 46 | echo " println! \"Running fake lints...\"" 47 | echo " println! \"Fake lints passed!\"" 48 | echo " return 0" 49 | } >> lakefile.lean 50 | shell: bash 51 | 52 | - name: "run `lean-action` with auto-config: true" 53 | id: lean-action 54 | uses: ./ 55 | with: 56 | auto-config: true 57 | use-github-cache: false 58 | 59 | - name: verify `lean-action` outcome success 60 | env: 61 | OUTPUT_NAME: "lean-action.outcome" 62 | EXPECTED_VALUE: "success" 63 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 64 | run: .github/functional_tests/test_helpers/verify_action_output.sh 65 | shell: bash 66 | 67 | - name: verify `lake build` success 68 | env: 69 | OUTPUT_NAME: "build-status" 70 | EXPECTED_VALUE: "SUCCESS" 71 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 72 | run: .github/functional_tests/test_helpers/verify_action_output.sh 73 | shell: bash 74 | 75 | - name: verify `lake test` success 76 | env: 77 | OUTPUT_NAME: "test-status" 78 | EXPECTED_VALUE: "SUCCESS" 79 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 80 | run: .github/functional_tests/test_helpers/verify_action_output.sh 81 | shell: bash 82 | 83 | - name: verify `lake lint` success 84 | env: 85 | OUTPUT_NAME: "lint-status" 86 | EXPECTED_VALUE: "SUCCESS" 87 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.lint-status }} 88 | run: .github/functional_tests/test_helpers/verify_action_output.sh 89 | shell: bash 90 | 91 | 92 | - name: "run `lean-action` with auto-config: true and false feature inputs" 93 | id: lean-action-false-feature-inputs 94 | uses: ./ 95 | with: 96 | auto-config: true 97 | build: false 98 | test: false 99 | lint: false 100 | use-github-cache: false 101 | - name: verify `lake build` did not run 102 | env: 103 | OUTPUT_NAME: "build-status" 104 | EXPECTED_VALUE: "" 105 | ACTUAL_VALUE: ${{ steps.lean-action-false-feature-inputs.outputs.build-status }} 106 | run: .github/functional_tests/test_helpers/verify_action_output.sh 107 | shell: bash 108 | 109 | - name: verify `lake test` did not run 110 | env: 111 | OUTPUT_NAME: "test-status" 112 | EXPECTED_VALUE: "" 113 | ACTUAL_VALUE: ${{ steps.lean-action-false-feature-inputs.outputs.test-status }} 114 | run: .github/functional_tests/test_helpers/verify_action_output.sh 115 | shell: bash 116 | 117 | - name: verify `lake lint` did not run 118 | env: 119 | OUTPUT_NAME: "lint-status" 120 | EXPECTED_VALUE: "" 121 | ACTUAL_VALUE: ${{ steps.lean-action-false-feature-inputs.outputs.lint-status }} 122 | run: .github/functional_tests/test_helpers/verify_action_output.sh 123 | shell: bash 124 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_build_args/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Build Args' 2 | description: 'Run `lean-action` on with `build-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 buildargs .lean 21 | lake update 22 | shell: bash 23 | 24 | - name: "run `lean-action` with build-args" 25 | id: lean-action 26 | uses: ./ 27 | with: 28 | build-args: "--wfail" 29 | use-github-cache: false 30 | 31 | - name: verify `lean-action` outcome success 32 | env: 33 | OUTPUT_NAME: "lean-action.outcome" 34 | EXPECTED_VALUE: "success" 35 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 36 | run: .github/functional_tests/test_helpers/verify_action_output.sh 37 | shell: bash 38 | 39 | - name: verify `lake build` success 40 | env: 41 | OUTPUT_NAME: "build-status" 42 | EXPECTED_VALUE: "SUCCESS" 43 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 44 | run: .github/functional_tests/test_helpers/verify_action_output.sh 45 | shell: bash 46 | 47 | - name: lake clean 48 | run: lake clean 49 | shell: bash 50 | 51 | - name: "run `lean-action` with multiple build args" 52 | id: lean-action-multiple-build-args 53 | uses: ./ 54 | with: 55 | build-args: "--log-level=warning --fail-level=warning" 56 | use-github-cache: false 57 | 58 | - name: verify `lean-action-multiple-build-args` outcome success 59 | env: 60 | OUTPUT_NAME: "lean-action-multiple-build-args.outcome" 61 | EXPECTED_VALUE: "success" 62 | ACTUAL_VALUE: ${{ steps.lean-action-multiple-build-args.outcome }} 63 | run: .github/functional_tests/test_helpers/verify_action_output.sh 64 | shell: bash 65 | 66 | - name: verify `lake build` success 67 | env: 68 | OUTPUT_NAME: "build-status" 69 | EXPECTED_VALUE: "SUCCESS" 70 | ACTUAL_VALUE: ${{ steps.lean-action-multiple-build-args.outputs.build-status }} 71 | run: .github/functional_tests/test_helpers/verify_action_output.sh 72 | shell: bash 73 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_check_test_failure/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Check Test Failure' 2 | description: | 3 | Run `lean-action` with `test: true` without a test_driver in the Lake workspace. 4 | Verify `lean-action` fails and `lake build` and `lake test` are not run. 5 | inputs: 6 | toolchain: 7 | description: 'Toolchain to use for the test' 8 | required: true 9 | runs: 10 | using: 'composite' 11 | steps: 12 | # TODO: once `lean-action` supports just setup, use it here 13 | - name: install elan 14 | run: | 15 | set -o pipefail 16 | curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain ${{ inputs.toolchain }} 17 | echo "$HOME/.elan/bin" >> "$GITHUB_PATH" 18 | shell: bash 19 | 20 | - name: create lake package 21 | run: | 22 | lake init dummytest 23 | lake update 24 | shell: bash 25 | 26 | - name: "run `lean-action` with `test: true`" 27 | id: lean-action 28 | uses: ./ 29 | continue-on-error: true # required so that the action failure does not fail the workflow 30 | with: 31 | test: true 32 | use-github-cache: false 33 | 34 | - name: verify `lean-action` outcome failure 35 | env: 36 | OUTPUT_NAME: "lean-action.outcome" 37 | EXPECTED_VALUE: "failure" 38 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 39 | run: .github/functional_tests/test_helpers/verify_action_output.sh 40 | shell: bash 41 | 42 | - name: verify `lake build` not run 43 | env: 44 | OUTPUT_NAME: "build-status" 45 | EXPECTED_VALUE: "" 46 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 47 | run: .github/functional_tests/test_helpers/verify_action_output.sh 48 | shell: bash 49 | 50 | - name: verify `lake test` not run 51 | env: 52 | OUTPUT_NAME: "test-status" 53 | EXPECTED_VALUE: "" 54 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 55 | run: .github/functional_tests/test_helpers/verify_action_output.sh 56 | shell: bash 57 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_init_failure/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Init Failure Functional Test' 2 | description: 'Run `lean-action` on Lake package generated by `lake init` with a modified `lakefile.lean` to cause a build failure' 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` 19 | run: | 20 | lake init failingpackage 21 | lake update 22 | shell: bash 23 | 24 | - name: introduce a syntax error in `lakefile.lean` 25 | run: | 26 | echo "syntax error" >> lakefile.lean 27 | shell: bash 28 | 29 | - name: "run `lean-action`" 30 | id: lean-action 31 | uses: ./ 32 | continue-on-error: true # required so that the action does not fail the workflow 33 | with: 34 | test: false 35 | use-github-cache: false 36 | 37 | - name: verify `lean-action` outcome failure 38 | env: 39 | OUTPUT_NAME: "lean-action outcome" 40 | EXPECTED_VALUE: "failure" 41 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 42 | run: .github/functional_tests/test_helpers/verify_action_output.sh 43 | shell: bash 44 | 45 | - name: verify `lake build` failure 46 | env: 47 | OUTPUT_NAME: "build-status" 48 | EXPECTED_VALUE: "FAILURE" 49 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 50 | run: .github/functional_tests/test_helpers/verify_action_output.sh 51 | shell: bash 52 | 53 | - name: verify `lake test` didn't run 54 | env: 55 | OUTPUT_NAME: "test-status" 56 | EXPECTED_VALUE: "" 57 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 58 | run: .github/functional_tests/test_helpers/verify_action_output.sh 59 | shell: bash 60 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_init_success/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Init Success Functional Test' 2 | description: 'Run `lean-action` on Lake package generated by `lake init`' 3 | inputs: 4 | lake-init-arguments: 5 | description: 'arguments to pass to `lake init {lake-init-arguments}`' 6 | required: true 7 | toolchain: 8 | description: 'Toolchain to use for the test' 9 | required: true 10 | runs: 11 | using: 'composite' 12 | steps: 13 | # TODO: once `lean-action` supports just setup, use it here 14 | - name: install elan 15 | run: | 16 | set -o pipefail 17 | curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain ${{ inputs.toolchain }} 18 | echo "$HOME/.elan/bin" >> "$GITHUB_PATH" 19 | shell: bash 20 | 21 | - name: create lake package with `lake init ${{ inputs.lake-init-arguments }}` 22 | run: | 23 | lake init ${{ inputs.lake-init-arguments }} 24 | lake update 25 | shell: bash 26 | 27 | - name: "run `lean-action`" 28 | id: lean-action 29 | uses: ./ 30 | with: 31 | use-github-cache: false 32 | 33 | - name: verify `lean-action` outcome success 34 | env: 35 | OUTPUT_NAME: "lean-action.outcome" 36 | EXPECTED_VALUE: "success" 37 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 38 | run: .github/functional_tests/test_helpers/verify_action_output.sh 39 | shell: bash 40 | 41 | - name: verify `lake build` success 42 | env: 43 | OUTPUT_NAME: "build-status" 44 | EXPECTED_VALUE: "SUCCESS" 45 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 46 | run: .github/functional_tests/test_helpers/verify_action_output.sh 47 | shell: bash 48 | 49 | - name: verify `lake test` didn't run 50 | env: 51 | OUTPUT_NAME: "test-status" 52 | EXPECTED_VALUE: "" 53 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 54 | run: .github/functional_tests/test_helpers/verify_action_output.sh 55 | shell: bash 56 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_lint_failure/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Lint Failure' 2 | description: 'Run `lean-action` with `lake lint` with a failing dummy lint_driver' 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 19 | run: | 20 | lake init dummylint .lean 21 | lake update 22 | shell: bash 23 | 24 | - name: create failing dummy lint driver 25 | run: | 26 | { 27 | echo "@[lint_driver]" 28 | echo "script dummy_lint do" 29 | echo " println! \"Running fake lint...\"" 30 | echo " println! \"Fake lint failed!\"" 31 | echo " return 1" 32 | } >> lakefile.lean 33 | shell: bash 34 | 35 | - name: "run `lean-action` with `lake lint`" 36 | id: lean-action 37 | uses: ./ 38 | continue-on-error: true # required so that the action does not fail the workflow 39 | with: 40 | lint: true 41 | use-github-cache: false 42 | 43 | - name: verify `lean-action` outcome failure 44 | env: 45 | OUTPUT_NAME: "lean-action outcome" 46 | EXPECTED_VALUE: "failure" 47 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 48 | run: .github/functional_tests/test_helpers/verify_action_output.sh 49 | shell: bash 50 | 51 | - name: verify `lake build` success 52 | env: 53 | OUTPUT_NAME: "build-status" 54 | EXPECTED_VALUE: "SUCCESS" 55 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 56 | run: .github/functional_tests/test_helpers/verify_action_output.sh 57 | shell: bash 58 | 59 | - name: verify `lake lint` failure 60 | env: 61 | OUTPUT_NAME: "lint-status" 62 | EXPECTED_VALUE: "FAILURE" 63 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.lint-status }} 64 | run: .github/functional_tests/test_helpers/verify_action_output.sh 65 | shell: bash 66 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_lint_success/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Lint Success' 2 | description: 'Run `lean-action` with `lake lint` and a successful dummy lint_driver' 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 19 | run: | 20 | lake init dummylint .lean 21 | lake update 22 | shell: bash 23 | 24 | - name: create successful dummy lint 25 | run: | 26 | { 27 | echo "@[lint_driver]" 28 | echo "script dummy_lint do" 29 | echo " println! \"Running fake lints...\"" 30 | echo " println! \"Fake lints passed!\"" 31 | echo " return 0" 32 | } >> lakefile.lean 33 | shell: bash 34 | 35 | - name: "run `lean-action` with `lake lint`" 36 | id: lean-action 37 | uses: ./ 38 | with: 39 | lint: true 40 | use-github-cache: false 41 | 42 | - name: verify `lean-action` outcome success 43 | env: 44 | OUTPUT_NAME: "lean-action.outcome" 45 | EXPECTED_VALUE: "success" 46 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 47 | run: .github/functional_tests/test_helpers/verify_action_output.sh 48 | shell: bash 49 | 50 | - name: verify `lake lint` success 51 | env: 52 | OUTPUT_NAME: "lint-status" 53 | EXPECTED_VALUE: "SUCCESS" 54 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.lint-status }} 55 | run: .github/functional_tests/test_helpers/verify_action_output.sh 56 | shell: bash 57 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_test_failure/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Test Failure' 2 | description: 'Run `lean-action` with `lake test` with a failing dummy test_runner' 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 19 | run: | 20 | lake init dummytest .lean 21 | lake update 22 | shell: bash 23 | 24 | - name: create failing dummy test 25 | run: | 26 | { 27 | echo "@[test_runner]" 28 | echo "script dummy_test do" 29 | echo " println! \"Running fake tests...\"" 30 | echo " println! \"Fake tests failed!\"" 31 | echo " return 1" 32 | } >> lakefile.lean 33 | shell: bash 34 | 35 | - name: "run `lean-action` with `lake test`" 36 | id: lean-action 37 | uses: ./ 38 | continue-on-error: true # required so that the action does not fail the workflow 39 | with: 40 | test: true 41 | use-github-cache: false 42 | 43 | - name: verify `lean-action` outcome failure 44 | env: 45 | OUTPUT_NAME: "lean-action outcome" 46 | EXPECTED_VALUE: "failure" 47 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 48 | run: .github/functional_tests/test_helpers/verify_action_output.sh 49 | shell: bash 50 | 51 | - name: verify `lake build` success 52 | env: 53 | OUTPUT_NAME: "build-status" 54 | EXPECTED_VALUE: "SUCCESS" 55 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 56 | run: .github/functional_tests/test_helpers/verify_action_output.sh 57 | shell: bash 58 | 59 | - name: verify `lake test` failure 60 | env: 61 | OUTPUT_NAME: "test-status" 62 | EXPECTED_VALUE: "FAILURE" 63 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 64 | run: .github/functional_tests/test_helpers/verify_action_output.sh 65 | shell: bash 66 | -------------------------------------------------------------------------------- /.github/functional_tests/lake_test_success/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Lake Test Success' 2 | description: 'Run `lean-action` with `lake test` and a successful dummy test_runner' 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 19 | run: | 20 | lake init dummytest .lean 21 | lake update 22 | shell: bash 23 | 24 | - name: create successful dummy test 25 | run: | 26 | { 27 | echo "@[test_runner]" 28 | echo "script dummy_test do" 29 | echo " println! \"Running fake tests...\"" 30 | echo " println! \"Fake tests passed!\"" 31 | echo " return 0" 32 | } >> lakefile.lean 33 | shell: bash 34 | 35 | - name: "run `lean-action` with `lake test`" 36 | id: lean-action 37 | uses: ./ 38 | with: 39 | test: true 40 | use-github-cache: false 41 | 42 | - name: verify `lean-action` outcome success 43 | env: 44 | OUTPUT_NAME: "lean-action.outcome" 45 | EXPECTED_VALUE: "success" 46 | ACTUAL_VALUE: ${{ steps.lean-action.outcome }} 47 | run: .github/functional_tests/test_helpers/verify_action_output.sh 48 | shell: bash 49 | 50 | - name: verify `lake test` success 51 | env: 52 | OUTPUT_NAME: "test-status" 53 | EXPECTED_VALUE: "SUCCESS" 54 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 55 | run: .github/functional_tests/test_helpers/verify_action_output.sh 56 | shell: bash 57 | -------------------------------------------------------------------------------- /.github/functional_tests/mathlib_dependency/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Mathlib Dependency Test' 2 | description: 'Run `lean-action` on Lake package generated by `lake init mathlibdep math` and verify that the mathlb dependecy is detected' 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 mathlibdep math` 19 | run: | 20 | lake init mathlibdep math 21 | lake update 22 | shell: bash 23 | 24 | - name: "run `lean-action`" 25 | id: lean-action 26 | uses: ./ 27 | with: 28 | use-github-cache: false 29 | 30 | - name: verify `lake build` success 31 | env: 32 | OUTPUT_NAME: "build-status" 33 | EXPECTED_VALUE: "SUCCESS" 34 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 35 | run: .github/functional_tests/test_helpers/verify_action_output.sh 36 | shell: bash 37 | 38 | 39 | - name: verify lean-action detected mathlib dependecy 40 | env: 41 | OUTPUT_NAME: "detected-mathlib" 42 | EXPECTED_VALUE: "true" 43 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.detected-mathlib }} 44 | run: .github/functional_tests/test_helpers/verify_action_output.sh 45 | shell: bash 46 | -------------------------------------------------------------------------------- /.github/functional_tests/reinstall-transient-toolchain/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Reinstall Transient Toolchain Functional Test' 2 | description: | 3 | Run `lean-action` with `reinstall-transient-toolchain: true`. 4 | Verify that the toolchain will be redownloaded. 5 | inputs: 6 | toolchain: 7 | description: 'Toolchain to use for `lake init` (not the toolchain that will be tested for reinstallation).' 8 | required: true 9 | runs: 10 | using: 'composite' 11 | steps: 12 | # TODO: once `lean-action` supports just setup, use it here 13 | - name: install elan 14 | run: | 15 | set -o pipefail 16 | curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain ${{ inputs.toolchain }} 17 | echo "$HOME/.elan/bin" >> "$GITHUB_PATH" 18 | shell: bash 19 | 20 | - name: create lake package 21 | run: | 22 | lake init transienttoolchain .lean 23 | lake update 24 | shell: bash 25 | 26 | - name: set a toolchain 27 | run: | 28 | echo "leanprover/lean4-pr-releases:pr-release-6627" > lean-toolchain 29 | shell: bash 30 | 31 | - name: "run `lean-action` to install the toolchain" 32 | id: lean-action-install 33 | uses: ./ 34 | with: 35 | auto-config: true 36 | use-github-cache: false 37 | 38 | - name: verify the toolchain is installed 39 | run: | 40 | elan toolchain list | grep -qFx "leanprover/lean4-pr-releases:pr-release-6627" 41 | shell: bash 42 | 43 | - name: verify `lean-action` outcome success 44 | env: 45 | OUTPUT_NAME: "lean-action-install.outcome" 46 | EXPECTED_VALUE: "success" 47 | ACTUAL_VALUE: ${{ steps.lean-action-install.outcome }} 48 | run: .github/functional_tests/test_helpers/verify_action_output.sh 49 | shell: bash 50 | 51 | - name: "run `lean-action` to uninstall the toolchain" 52 | id: lean-action-uninstall 53 | uses: ./ 54 | with: 55 | reinstall-transient-toolchain: true 56 | auto-config: false 57 | use-github-cache: false 58 | 59 | - name: verify the toolchain is no longer installed 60 | run: | 61 | ! elan toolchain list | grep -qFx "leanprover/lean4-pr-releases:pr-release-6627" 62 | shell: bash 63 | 64 | - name: verify `lean-action` outcome success 65 | env: 66 | OUTPUT_NAME: "lean-action.outcome" 67 | EXPECTED_VALUE: "success" 68 | ACTUAL_VALUE: ${{ steps.lean-action-uninstall.outcome }} 69 | run: .github/functional_tests/test_helpers/verify_action_output.sh 70 | shell: bash 71 | -------------------------------------------------------------------------------- /.github/functional_tests/subdirectory_lake_package/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Subdirectory Lake Package Functional Test' 2 | description: | 3 | Run `lean-action` with the `lake-package-directory` input 4 | on Lake package generated by `lake init` in a subdirectory of the repository. 5 | inputs: 6 | toolchain: 7 | description: 'Toolchain to use for the test' 8 | required: true 9 | runs: 10 | using: 'composite' 11 | steps: 12 | # TODO: once `lean-action` supports just setup, use it here 13 | - name: install elan 14 | run: | 15 | set -o pipefail 16 | curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain ${{ inputs.toolchain }} 17 | echo "$HOME/.elan/bin" >> "$GITHUB_PATH" 18 | shell: bash 19 | 20 | - name: create Lake package in a_subdirectory 21 | run: | 22 | mkdir a_subdirectory 23 | cd a_subdirectory 24 | lake init subdirpackage 25 | lake update 26 | shell: bash 27 | 28 | - name: "run `lean-action`" 29 | id: lean-action 30 | uses: ./ 31 | with: 32 | use-github-cache: false 33 | lake-package-directory: "a_subdirectory" 34 | 35 | - name: verify `lake build` success 36 | env: 37 | OUTPUT_NAME: "build-status" 38 | EXPECTED_VALUE: "SUCCESS" 39 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.build-status }} 40 | run: .github/functional_tests/test_helpers/verify_action_output.sh 41 | shell: bash 42 | 43 | - name: verify `lake test` didn't run 44 | env: 45 | OUTPUT_NAME: "test-status" 46 | EXPECTED_VALUE: "" 47 | ACTUAL_VALUE: ${{ steps.lean-action.outputs.test-status }} 48 | run: .github/functional_tests/test_helpers/verify_action_output.sh 49 | shell: bash 50 | -------------------------------------------------------------------------------- /.github/functional_tests/test_helpers/verify_action_output.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Expects the following environment variables to be set in the calling job step: 4 | # - OUTPUT_NAME: the name of the output to verify 5 | # - EXPECTED_VALUE: the expected value of the output 6 | # - ACTUAL_VALUE: the actual value of the output 7 | if [ "$ACTUAL_VALUE" != "$EXPECTED_VALUE" ]; then 8 | echo "Unexpected value for output $OUTPUT_NAME: $ACTUAL_VALUE (expected: $EXPECTED_VALUE)" 9 | exit 1 10 | fi 11 | echo "Output $OUTPUT_NAME = $EXPECTED_VALUE verified" 12 | -------------------------------------------------------------------------------- /.github/issue_templates/release_template.md: -------------------------------------------------------------------------------- 1 | Before creating an issue with this template, 2 | 3 | - replace `{{MAJOR_RELEASE}}` with the current major release, e.g., `v1`. 4 | - replace `{{SPECIFIC_RELEASE}}` with the specific release tag, e.g., `v1.0.0` or `v1.1.3`. 5 | - remove any todos that start with {{REMOVE IF NOT MAJOR RELEASE}} if this isn't a major release. 6 | 7 | # {{SPECIFIC_RELEASE}} 8 | 9 | - [ ] Create a `release/{{SPECIFIC_RELEASE}}` branch off of `main` for the release candidate. 10 | - Testing 11 | - [ ] Run `functional_tests.yml` workflow on `release/{{SPECIFIC_RELEASE}}`. 12 | - [ ] Create a GitHub release of `release/{{SPECIFIC_RELEASE}}` with a `{{SPECIFIC_RELEASE}}` tag. 13 | - [ ] Copy the release notes from the ## Unreleased section of CHANGELOG.md. 14 | - [ ] After the release is created, verify a git tag named `{{SPECIFIC_RELEASE}}` is pointing to the `release/{{SPECIFIC_RELEASE}}` branch 15 | - Git tag manipulation. 16 | - [ ] {{REMOVE IF NOT MAJOR RELEASE}} Create a new git tag named `{{MAJOR_RELEASE}}`. 17 | - [ ] Move the `{{MAJOR_RELEASE}}` tag to point to `release/{{SPECIFIC_RELEASE}}`. 18 | - [ ] Verify action with `uses: leanprover/lean-action@{{SPECIFIC_RELEASE}}` in test repo as a sanity check. 19 | - Create a PR to: 20 | - [ ] Create a PR to update CHANGELOG.md with the latest release. 21 | - [ ] {{REMOVE IF NOT MAJOR RELEASE}} Update instances of `leanprover/lean-action@{{MAJOR_RELEASE}}` in README.md. 22 | - [ ] Post release announcement in `general/lean-action` Zulip topic. 23 | -------------------------------------------------------------------------------- /.github/workflows/actionlint.yml: -------------------------------------------------------------------------------- 1 | name: Actionlint 2 | on: 3 | push: 4 | branches: 5 | - 'main' 6 | paths: 7 | - '.github/**' 8 | pull_request: 9 | paths: 10 | - '.github/**' 11 | 12 | jobs: 13 | actionlint: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | - name: actionlint 19 | uses: raven-actions/actionlint@v2 20 | with: 21 | pyflakes: false # we do not use python scripts 22 | -------------------------------------------------------------------------------- /.github/workflows/functional_tests.yml: -------------------------------------------------------------------------------- 1 | name: Functional Tests 2 | 3 | on: 4 | pull_request: 5 | branches: [main] 6 | paths: 7 | - "scripts/**" 8 | - "action.yml" 9 | - ".github/workflows/functional_tests.yml" 10 | - ".github/functional_tests/**" 11 | workflow_dispatch: 12 | inputs: 13 | toolchain: 14 | description: "The Lean toolchain to use when running the tests." 15 | required: false 16 | default: "leanprover/lean4:v4.16.0" 17 | 18 | # This environment variable is necessary in addition to the workflow_dispatch input 19 | # because the workflow_dispatch input is not available when the workflow is triggered by a pull request 20 | env: 21 | toolchain: ${{ github.event.inputs.toolchain || 'leanprover/lean4:v4.16.0' }} 22 | 23 | jobs: 24 | lake-init-success: 25 | runs-on: ubuntu-latest 26 | strategy: 27 | matrix: 28 | # run `lean-action` on a package generated with `lake init` for: 29 | # - a standalone package 30 | # - a package with a mathlib dependency 31 | # - a package with a `lakefile.toml` file 32 | # see ./github/functional_tests/lake_init/action.yml for more details on lake-init-arguments 33 | lake-init-arguments: ["standalone", "mathdep math", "tomltest .toml"] 34 | steps: 35 | - uses: actions/checkout@v4 36 | - uses: ./.github/functional_tests/lake_init_success 37 | with: 38 | lake-init-arguments: ${{ matrix.lake-init-arguments}} 39 | toolchain: ${{ env.toolchain }} 40 | 41 | lake-init-failure: 42 | runs-on: ubuntu-latest 43 | steps: 44 | - uses: actions/checkout@v4 45 | - uses: ./.github/functional_tests/lake_init_failure 46 | with: 47 | toolchain: ${{ env.toolchain }} 48 | 49 | auto-config-true: 50 | runs-on: ubuntu-latest 51 | steps: 52 | - uses: actions/checkout@v4 53 | - uses: ./.github/functional_tests/auto_config_true 54 | with: 55 | toolchain: ${{ env.toolchain }} 56 | 57 | auto-config-false: 58 | runs-on: ubuntu-latest 59 | steps: 60 | - uses: actions/checkout@v4 61 | - uses: ./.github/functional_tests/auto_config_false 62 | with: 63 | toolchain: ${{ env.toolchain }} 64 | 65 | lake-build-args: 66 | runs-on: ubuntu-latest 67 | steps: 68 | - uses: actions/checkout@v4 69 | - uses: ./.github/functional_tests/lake_build_args 70 | with: 71 | toolchain: ${{ env.toolchain }} 72 | 73 | detect-mathlib: 74 | runs-on: ubuntu-latest 75 | steps: 76 | - uses: actions/checkout@v4 77 | - uses: ./.github/functional_tests/mathlib_dependency 78 | with: 79 | toolchain: ${{ env.toolchain }} 80 | 81 | lake-test-success: 82 | runs-on: ubuntu-latest 83 | steps: 84 | - uses: actions/checkout@v4 85 | - uses: ./.github/functional_tests/lake_test_success 86 | with: 87 | toolchain: ${{ env.toolchain }} 88 | 89 | lake-test-failure: 90 | runs-on: ubuntu-latest 91 | steps: 92 | - uses: actions/checkout@v4 93 | - uses: ./.github/functional_tests/lake_test_failure 94 | with: 95 | toolchain: ${{ env.toolchain }} 96 | 97 | lake-lint-success: 98 | runs-on: ubuntu-latest 99 | steps: 100 | - uses: actions/checkout@v4 101 | - uses: ./.github/functional_tests/lake_lint_success 102 | with: 103 | toolchain: ${{ env.toolchain }} 104 | 105 | lake-lint-failure: 106 | runs-on: ubuntu-latest 107 | steps: 108 | - uses: actions/checkout@v4 109 | - uses: ./.github/functional_tests/lake_lint_failure 110 | with: 111 | toolchain: ${{ env.toolchain }} 112 | 113 | lake-check-test-failure: 114 | runs-on: ubuntu-latest 115 | steps: 116 | - uses: actions/checkout@v4 117 | - uses: ./.github/functional_tests/lake_check_test_failure 118 | with: 119 | toolchain: ${{ env.toolchain }} 120 | 121 | subdirectory-lake-package: 122 | runs-on: ubuntu-latest 123 | steps: 124 | - uses: actions/checkout@v4 125 | - uses: ./.github/functional_tests/subdirectory_lake_package 126 | with: 127 | toolchain: ${{ env.toolchain }} 128 | 129 | reinstall-transient-toolchain: 130 | runs-on: ubuntu-latest 131 | steps: 132 | - uses: actions/checkout@v4 133 | - uses: ./.github/functional_tests/reinstall-transient-toolchain 134 | with: 135 | toolchain: ${{ env.toolchain }} 136 | 137 | macos-runner: 138 | runs-on: macos-latest 139 | steps: 140 | - uses: actions/checkout@v4 141 | - uses: ./.github/functional_tests/lake_init_success 142 | with: 143 | lake-init-arguments: "standalone" 144 | toolchain: ${{ env.toolchain }} 145 | 146 | windows-runner: 147 | runs-on: windows-latest 148 | steps: 149 | - uses: actions/checkout@v4 150 | - uses: ./.github/functional_tests/lake_init_success 151 | with: 152 | lake-init-arguments: "standalone" 153 | toolchain: ${{ env.toolchain }} 154 | 155 | -------------------------------------------------------------------------------- /.github/workflows/shellcheck.yml: -------------------------------------------------------------------------------- 1 | name: ShellCheck 2 | on: 3 | push: 4 | branches: 5 | - 'main' 6 | pull_request: 7 | 8 | jobs: 9 | lint: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v4 14 | - name: Run ShellCheck 15 | uses: azohra/shell-linter@v0.8.0 16 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `lean-action` will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## Unreleased 9 | 10 | ## v1.2.0 - 2025-05-16 11 | 12 | ### Added 13 | 14 | - add option to always reinstall `lean4-pr-releases` toolchains, ensuring CI runs with the latest version 15 | 16 | ## v1.1.2 - 2025-03-28 17 | 18 | ### Fixed 19 | 20 | - include runner architecture in cache key to avoid reusing `.lake` across different runner architectures 21 | 22 | ## v1.1.1 - 2024-11-23 23 | 24 | ### Fixed 25 | 26 | - fix bug with passing multiple arguments to `lake build` via `build-args` input 27 | - fix false feature flag logic when using `auto-config: true` 28 | 29 | ## v1.1.0 - 2024-9-16 30 | 31 | ### Added 32 | 33 | - Windows GitHub runner support 34 | 35 | ### Fixed 36 | 37 | - replace `actions/cache` with `actions/cache/restore` to prevent redundant cache saving 38 | previously caused by the combination of `actions/cache` and `actions/cache/save` 39 | 40 | ## v1.0.2 - 2024-8-26 41 | 42 | ### Changed 43 | 44 | - use empty string as default value for status outputs instead of "NOT_RUN" 45 | to avoid `set-output-parameters` final step breaking log group expansion 46 | 47 | ### Fixed 48 | 49 | - correct typo of in configuration step: "lake check-test failed" -> "lake check-lint failed" 50 | - fix log group expansion in failing steps due to `set-output-parameters` step 51 | and removing the end log group command when a step fails 52 | 53 | ## v1.0.1 - 2024-8-20 54 | 55 | ### Changed 56 | 57 | - use lake-manifest.json to detect mathlib dependency instead of lakefile.{lean, toml} 58 | to make lean-action more robust to changes in the configuration file formatting. 59 | 60 | ### Fixed 61 | 62 | - switch elan installation method from download platform tar to `elan-init.sh` 63 | to support addition runners, e.g., macos. 64 | 65 | ## v1.0.0 - 2024-07-20 66 | 67 | ### Added 68 | 69 | - new `auto-config` input 70 | to specify if `lean-action` should use the Lake workspace 71 | to automatically determine which CI features to run, i.e., `lake build`, `lake test`, `lake lint`. 72 | - new `build` input to specify if `lean-action` should run `lake build` 73 | - new `lint` input to specify if `lean-action` should run `lake lint` 74 | - parameterize functional tests by Lean toolchain to allow for testing `lean-action` on any Lean version. 75 | 76 | ### Changed 77 | 78 | - `test` input now defaults to `auto-config`. 79 | Users can still specify `test: true` to force `lean-action` to run `lake test`. 80 | - removed `lint-module` input. 81 | Users should now use a `@[lint_driver]` to integrate with the `Batteries` testing framework. 82 | 83 | ### Fixed 84 | 85 | - improved GitHub cache keys 86 | to make caching more efficient and avoid edge cases when upgrading Lean version. 87 | 88 | ## v1-beta.1 - 2024-06-21 89 | 90 | ### Added 91 | 92 | - new `use-github-cache` input to specify if `lean-action` should use `actions/cache` to cache the `.lake` folder 93 | - `build-status` and `test-status` output parameters 94 | - new `lake-package-directory` input to specify the directory to run Lake commands. 95 | This input will enable users to use `lean-action` when Lake packages are contained in repository subdirectories. 96 | - new `auto-config` input to configure `lean-action` to use the Lake workspace to decide which steps to run 97 | 98 | ### Changed 99 | 100 | - upgrade elan version to `v3.1.1` 101 | - run `lake check-test` before running `lake test` 102 | - improved log readability with explicit log group naming and additional white space 103 | 104 | ### Fixed 105 | 106 | - remove misleading .toml error message in mathlib detection 107 | - remove `elan-init` file after elan installation 108 | 109 | ## v1-beta.0 - 2024-05-21 110 | 111 | ### Added 112 | 113 | - logs are grouped by step for better readability 114 | - new `build-args` input to specify arguments to pass to `lake build` 115 | - install elan step logs `lean --version` and `lake --version` 116 | 117 | ### Changed 118 | 119 | - `lean-action` no longer contains an `actions/checkout` step 120 | - `mathlib-cache` renamed to `get-mathlib-cache` 121 | 122 | ### Fixed 123 | 124 | - improved default value for `get-mathlib-cache` 125 | 126 | ## v1-alpha - 2024-05-12 127 | 128 | ### Added 129 | 130 | - build packages with `lake build` 131 | - run tests with `lake test` 132 | - automatically detect `mathlib` dependency and run `lake exe get cache` 133 | - detect [Reservoir eligibility](https://reservoir.lean-lang.org/inclusion-criteria) 134 | - check for environment hacking with lean4checker 135 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contribution Guidelines 2 | Follow Lean's [Commit Convention](https://github.com/leanprover/lean4/blob/master/doc/dev/commit_convention.md). 3 | 4 | For more information see the [PR Submission](https://github.com/leanprover/lean4/blob/master/CONTRIBUTING.md#pr-submission) section in lean4's CONTRIBUTING.md. 5 | 6 | Note this key detail: 7 | > Follow the commit convention: Pull requests are squash merged, and the commit message is taken from the pull request title and body, so make sure they adhere to the commit convention. Put questions and extra information, which should not be part of the final commit message, into a first comment rather than the Pull Request description. Because the change will be squashed, there is no need to polish the commit messages and history on the branch. 8 | 9 | If release notes should include changes introduced by your PR, add a bullet to the `## Unreleased` section in `CHANGELOG.md`. 10 | 11 | ## Testing 12 | The `lean-action` repository contains a set of functional tests 13 | to ensure changes do not introduce regressions to existing functionality. 14 | 15 | The `.github/functional_tests` directory contains GitHub actions 16 | which correspond to functional test cases for `lean-action`. 17 | 18 | As of now, the only entry point for functional tests is the `.github/workflow/functional_tests.yml` workflow, 19 | which runs when a PR proposes changes to critical files in the `lean-action` repository. 20 | In the future, we will likely introduce additional entry points for tests, 21 | such as a more comprehensive test suite for release candidates. 22 | 23 | ### Verifying `lean-action` outputs with `verify_action_output.sh` 24 | Functional tests use `verify_action_output.sh` (located in `.github/functional_tests/test_helpers`) 25 | along with a verification step in the test workflow 26 | to verify `lean-action` functions as expected in a given test scenario. 27 | 28 | See the `lake_test_failure` functional test for an example. 29 | 30 | ### Creating a new test 31 | When introducing new functionality to `lean-action`, consider creating a new functional test. 32 | Here are the steps to create a new test: 33 | - Create a new action corresponding to a test. 34 | - Create a subdirectory named after the test in `.github/functional_tests`. 35 | - Create an `action.yml` GitHub action file within the directory, which initializes the test and calls `lean-action`. 36 | - Write a meaningful description of what use cases your test covers. 37 | - Parameterize your test by the lean toolchain 38 | (see `.github/functional_tests/lake_init_failure/action.yml` for an example). 39 | - If appropriate, you can parameterize your test with additional action inputs for more flexibility 40 | (see the `.github/functional_tests/lake_init_success/action.yml` directory for an example). 41 | - For more information on the action syntax, 42 | see [creating a composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action). 43 | - Create a final step in your test which verifies the outputs of `lean-action` using `verify_action_output.sh`. 44 | - Create a new job in `.github/workflows/functional_tests.yml` with a call to the newly created action. 45 | 46 | ### Running functional tests with a specific Lean toolchain 47 | When triggered by a pull request, 48 | the `functional_tests.yml` workflow uses the Lean toolchain defined in the `toolchain` environment variable 49 | at the top of the `functional_tests.yml` workflow file. 50 | 51 | When `functional_tests.yml` is triggered by a manual workflow dispatch, 52 | users can specify the Lean toolchain as seen in the below screenshot. 53 | ![2024-06-26-09:18:19-screenshot](https://github.com/leanprover/lean-action/assets/21346448/7752b2c1-c986-4544-93ff-9a7864cd155c) 54 | 55 | ### Running functional tests locally with `act` 56 | `lean-action` developers can leverage [act](https://github.com/nektos/act) to run tests locally. 57 | 58 | Here are two useful commands: 59 | - Run all tests locally: `act workflow_dispatch '.github/workflows/functional_tests.yml'`. 60 | - Run a specific test by running a job within the `functional_tests.yml` workflow: 61 | `act workflow_dispatch -j {job-name} -W '.github/workflows/functional_tests.yml'`, 62 | e.g., `act workflow_dispatch -j lake-test -W '.github/workflows/functional_tests.yml'`. 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lean-action - CI for Lean Projects 2 | 3 | lean-action provides steps to build, test, and lint [Lean](https://github.com/leanprover/lean4) projects on GitHub 4 | 5 | ## Quick Setup 6 | 7 | To setup `lean-action` to run on pushes and pull request in your repo, create the following `ci.yml` file the `.github/workflows` 8 | 9 | ```yml 10 | name: CI 11 | 12 | on: 13 | push: 14 | branches: ["main"] # replace "main" with the default branch 15 | pull_request: 16 | branches: ["main"] 17 | workflow_dispatch: 18 | 19 | jobs: 20 | build: 21 | runs-on: ubuntu-latest 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | # uses lean standard action with all default input values 26 | - uses: leanprover/lean-action@v1 27 | ``` 28 | 29 | > [!IMPORTANT] 30 | `lean-action` is tested on `ubuntu-latest`, `macos-latest`, and `windows-latest` GitHub-hosted runners. 31 | We recommend using one of these runners for the best experience, 32 | however if you encounter an issue when using a different runner, please still open an issue. 33 | 34 | ## Caching `.lake` directory with GitHub's `actions\cache` 35 | By default, `lean-action` uses [`actions\cache`](https://github.com/actions/cache) to cache the `.lake` directory and speed up builds. 36 | 37 | > [!NOTE] 38 | GitHub caching is distinct from Mathlib caching with `lake exe cache get` 39 | 40 | ### Cache keys 41 | `lean-action` uses [cache keys](https://github.com/actions/cache?tab=readme-ov-file#creating-a-cache-key) to save and restore caches. 42 | 43 | First it uses a primary key, 44 | composed of the runner operating system, the runner architecture (X86, X64, ARM, ARM64), the Lake manifest, and the git commit hash, 45 | to save/restore caches from an exact git commit. 46 | 47 | If there is no primary key cache hit, `lean-action` uses a fallback key, 48 | composed of the operating system, the architecture, and the Lake manifest but not the git commit hash, 49 | to restore a cache from a previous commit. 50 | 51 | ### Troubleshooting problems with caching 52 | Because caches are shared across different jobs, 53 | caching build files can lead to unexpected behavior and errors. 54 | 55 | To determine if the GitHub cache is causing problems you can disable caching with the `use-github-cache` input. 56 | ```yml 57 | - uses: leanprover/lean-action@v1 58 | with: 59 | use-github-cache: false 60 | ``` 61 | 62 | For more complex workflows, you may want more control over how the `actions\cache` caches the build in your workflow, 63 | (.e.g., modifying the cache key to respect a build matrix) 64 | you can wrap `lean/action` with `use-github-cache: false` in your own call to `actions\cache`. 65 | 66 | ## Configuring which features `lean-action` runs 67 | 68 | Most use cases only require a subset of `lean-action`'s features 69 | in a specific GitHub workflow. 70 | Additionally, you may want to break up usage of `lean-action` 71 | across multiple workflows with different triggers, 72 | e.g., one workflow for PRs and another workflow scheduled by a cron job. 73 | 74 | To support these use cases, 75 | `lean-action` provides inputs to specify the subset of desired features of `lean-action`. 76 | 77 | ### Directly specifying a desired feature with specific feature inputs 78 | 79 | Each feature of `lean-action` has a corresponding input which users can set to `true` or `false`. 80 | Specific feature inputs have the highest precedence 81 | when `lean-action` determines which features to run. 82 | When a feature input is set `lean-action` will always try to run the corresponding step. 83 | If `lean-action` is unable to successfully run the step, `lean-action` will fail. 84 | 85 | `lean-action` provides the following feature inputs: 86 | 87 | - `build` 88 | - `test` 89 | - `lint` 90 | - `check-reservoir-eligibility` 91 | - `lean4checker` 92 | 93 | ### Automatic configuration 94 | 95 | After feature inputs, `lean-action` uses the `auto-config` input 96 | to determine if it should use the Lake workspace to decide which steps to run automatically. 97 | When `auto-config: true`, `lean-action` will use the Lake workspace to detect targets 98 | and run the corresponding Lake command. 99 | When `auto-config: false`, `lean-action` will only run features specified directly through specific feature inputs. 100 | Users can combine `auto-config` with specific feature inputs to override the automatic configuration of `lean-action`. 101 | 102 | `lean-action` can automatically configure the following features: 103 | 104 | - `build` 105 | - `test` 106 | - `lint` 107 | 108 | ### Breaking up `lean-action` across workflows 109 | 110 | Sometimes it is useful to break up usage of `lean-action` 111 | across multiple workflows with different triggers, 112 | e.g., one workflow for PRs and another workflow scheduled by a cron job. 113 | `auto-config: false` allows users to run only a specific subset of features of `lean-action`. 114 | 115 | For example, run only `lean4checker` in a cron job workflow: 116 | 117 | ```yaml 118 | - name: "run `lean-action` with only `lean4checker: true`" 119 | id: lean-action 120 | uses: leanprover/lean-action@v1 121 | with: 122 | auto-config: false 123 | lean4checker: true 124 | ``` 125 | 126 | ### Differences between using `auto-config` and feature inputs 127 | 128 | When you specify a feature with a feature input, `lean-action` will fail if it can't complete that step. 129 | However, if you use `auto-config`, 130 | `lean-action` will only fail if it detects a target in the Lake workspace and the detected target fails. 131 | 132 | For example, if the `lakefile.lean` contains an improperly configured `test_driver` target 133 | and you configure `lean-action` with `test: true`, `lean-action` will fail. 134 | However the same improperly configured `test_driver` may not cause a `lean-action` failure with `auto-config: true`, 135 | because `lean-action` may not detect the `test_driver` in the Lake workspace. 136 | 137 | To be certain `lean-action` runs a step, specify the desire feature with a feature input. 138 | 139 | ## Customization 140 | 141 | `lean-action` provides optional configuration inputs to customize the behavior for your specific workflow. 142 | 143 | ```yaml 144 | - uses: leanprover/lean-action@v1 145 | with: 146 | 147 | # Automatically configure `lean-action` based on the Lake workspace. 148 | # When set to "true", `lean-action` will use the Lake workspace to determine 149 | # the set of features to run on the repository, such as `lake build` and `lake test`. 150 | # Even when set to "true", the user can still override the auto configuration 151 | # with the `build` and `test` inputs. 152 | # Allowed values: "true" or "false". 153 | # Default: "true" 154 | auto-config: "" 155 | 156 | # Run `lake build`. 157 | # Note, this input takes precedence over `auto-config`. 158 | # Allowed values: "true" | "false" | "default". 159 | build: "" 160 | 161 | # Run `lake test`. 162 | # Note, this input takes precedence over `auto-config`. 163 | # Allowed values: "true" | "false" | "default". 164 | test: "" 165 | 166 | # Run `lake lint`. 167 | # Note, this input takes precedence over `auto-config`. 168 | # Allowed values: "true" | "false" | "default". 169 | lint: "" 170 | 171 | # Build arguments to pass to `lake build {build-args}`. 172 | # For example, `build-args: "--quiet"` will run `lake build --quiet`. 173 | # By default, `lean-action` calls `lake build` with no arguments. 174 | build-args: "" 175 | 176 | # By default, `lean-action` attempts to automatically detect a Mathlib dependency and run `lake exe cache get` accordingly. 177 | # Setting `use-mathlib-cache` will override automatic detection and run (or not run) `lake exe cache get`. 178 | # Project must be downstream of Mathlib to use the Mathlib cache. 179 | # Allowed values: "true" | "false" | "auto". 180 | # Default: "auto" 181 | use-mathlib-cache: "" 182 | 183 | # Check if the repository is eligible for the Reservoir. 184 | # Allowed values: "true" | "false". 185 | # Default: "false" 186 | check-reservoir-eligibility: "" 187 | 188 | # Check environment with lean4checker. 189 | # Lean version must be 4.8 or higher. 190 | # The version of lean4checker is automatically detected using `lean-toolchain`. 191 | # Allowed values: "true" | "false". 192 | # Default: "false" 193 | lean4checker: "" 194 | 195 | # Enable GitHub caching. 196 | # Allowed values: "true" or "false". 197 | # If use-github-cache input is not provided, the action will use GitHub caching by default. 198 | # Default: "true" 199 | use-github-cache: "" 200 | 201 | # The directory where `lean-action` will look for a Lake package and run `lake build`, etc. 202 | # Allowed values: a valid directory containing a Lake package. 203 | # If lake-package-directory is not provided, `lean-action` will use the root directory of the repository by default. 204 | lake-package-directory: "" 205 | 206 | # Always reinstall the Lean toolchain if it is a transient one, hosted on the lean4-pr-releases repository. 207 | # This ensures that CI always uses the latest build of that toolchain. 208 | # This setting only applies to `lean4-pr-releases/pr-release-XXXX` toolchains: 209 | # regular Lean toolchain releases remain cached. 210 | # The toolchain version is determined from the `lean-toolchain` file. 211 | # Allowed values: "true" | "false". 212 | # Default: "false" 213 | reinstall-transient-toolchain: "" 214 | ``` 215 | 216 | ## Output Parameters 217 | 218 | `lean-action` provides the following output parameters for downstream steps: 219 | 220 | - `build-status` 221 | - Values: "SUCCESS" | "FAILURE" | "" 222 | - `test-status` 223 | - Values: "SUCCESS" | "FAILURE" | "" 224 | - `lint-status` 225 | - Values: "SUCCESS" | "FAILURE" | "" 226 | 227 | Note, a value of empty string indicates `lean-action` did not run the corresponding feature. 228 | 229 | ### Example: Use `test-status` output parameter in downstream step 230 | 231 | ```yaml 232 | - name: "run `lean-action` with `lake test`" 233 | id: lean-action 234 | uses: leanprover/lean-action@v1 235 | continue-on-error: true 236 | with: 237 | test: true 238 | 239 | - name: log `lean-action` `test-status` output 240 | env: 241 | TEST_STATUS: ${{ steps.lean-action.outputs.test-status }} 242 | run: echo "Test status: $TEST_STATUS" 243 | ``` 244 | 245 | ## Additional Examples 246 | 247 | ### Check package for reservoir eligibility 248 | 249 | ```yaml 250 | - uses: leanprover/lean-action@v1 251 | with: 252 | check-reservoir-eligibility: true 253 | ``` 254 | 255 | ### Don't run `lake test` or use Mathlib cache 256 | 257 | ```yaml 258 | - uses: leanprover/lean-action@v1 259 | with: 260 | test: false 261 | use-mathlib-cache: false 262 | ``` 263 | 264 | ### Run lake build with `--wfail` 265 | 266 | ```yaml 267 | - uses: leanprover/lean-action@v1 268 | with: 269 | build-args: "--wfail" 270 | ``` 271 | 272 | ### Run additional steps after `lean-action` using the Lean environment 273 | 274 | After calling `lean-action` you can leverage the Lean environment in later workflow steps. 275 | 276 | For example, `leanprover-community/import-graph` uses the setup from `lean-action` to test the `graph` executable with `lake exe graph`: 277 | 278 | ```yaml 279 | steps: 280 | - uses: leanprover/lean-action@v1 281 | with: 282 | check-reservoir-eligibility: true 283 | # use setup from lean-action to perform the following steps 284 | - name: verify `lake exe graph` works 285 | run: | 286 | lake exe graph 287 | rm import_graph.dot 288 | ``` 289 | 290 | ## Projects which use `lean-action` 291 | 292 | - [leanprover-community/aesop](https://github.com/leanprover-community/aesop/blob/master/.github/workflows/build.yml#L16) 293 | - [leanprover-community/import-graph](https://github.com/leanprover-community/import-graph/blob/main/.github/workflows/build.yml#L8) 294 | 295 | ## Keep the action updated with `dependabot` 296 | 297 | Because Lean is under heavy development, changes to Lean or Lake could break outdated versions of `lean-action`. You can configure [dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates) to automatically create a PR to update `lean-action` when a new stable version is released. 298 | 299 | Here is an example `.github/dependabot.yml` which configures `dependabot` to check daily for updates to all GitHub actions in your repository: 300 | 301 | ```yaml 302 | version: 2 303 | updates: 304 | - package-ecosystem: "github-actions" 305 | directory: "/" 306 | schedule: 307 | interval: "daily" 308 | ``` 309 | 310 | See the [dependabot documentation](https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file) for all configuration options. 311 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | # General notes 2 | `lean-action` uses git tags and [semantic versioning](https://semver.org/) for release management. For example: `v1`, `v2.7.1`, `v2-beta`. 3 | 4 | In short: 5 | - If a release changes the API of the inputs to `lean-action` or contains changes which would break backwards compatibility, bump the major version. 6 | - If a release introduces new features or changes the inputs API which does not break backwards compatibility (e.g. adds a new input which doesn't affect the other inputs), bump the minor version. 7 | - For bug fixes, bump the patch version. 8 | 9 | A major version tag is maintained for each version which points to the latest version of `lean-action`. Users will most often use `lean-action` with this major version tag. For example, if the latest version of `lean-action` is `v2.7.1`, `v2` should point to `v2.7.1`. 10 | 11 | For more information about releasing GitHub actions see the [Using tags for release management](https://docs.github.com/en/actions/creating-actions/about-custom-actions#using-tags-for-release-management) section of the GitHub custom actions documentation. 12 | 13 | ## Creating a release 14 | To create a release create an issue title `{RELEASE_VERSION} release` 15 | with the `.github/issue_templates/release_template.md` template 16 | and the `release` GitHub issue label. 17 | Follow the steps in the issue template. 18 | 19 | Here is an outline of the release process. There are more details in the release issue template. 20 | - Create a `release/v{RELEASE_VERSION}` branch (e.g. `release/v2.7.1`). 21 | - Run the `functional_test.yml` workflow on `release/lean-action@v{RELEASE_VERSION}`. 22 | - Make any minor commits related to the release on the release branch. 23 | - Once the release has been validated, create a new release with release notes copied from the `## Unreleased` section of `CHANGELOG.md` and a git tag `v{RELEASE_VERSION}` (e.g `v2.7.1`). 24 | - In the case of a minor or patch version, move the major version tag to the latest version 25 | - Update `CHANGELOG.md` with a new section with the release name and date directly below the `## Unreleased` header, e.g., `## v2.7.1 - 2024-12-21` . 26 | - If you made updates to the release notes in the GitHub release, add them to `CHANGELOG.md`. 27 | - If there are additional commits on the release branch, merge the release branch back into `main`. 28 | - Make an announcement to the Lean community. 29 | 30 | ## Special notes for major releases 31 | - Replace all instances of `leanprover/leanaction@{PREVIOUS_MAJOR_RELEASE_VERSION}` in `README.md` with `leanprover/lean-action@{NEW_MAJOR_RELEASE_VERSION}`. 32 | - Quickly do this with `sed -i 's/leanprover\/lean-action@v2/leanprover\/lean-action@v3/g' README.md` if releasing `v3`. 33 | - Clearly outline in the `README.md` and in communication to the Lean community what the migration strategy is to the new version if it is more involved than bumping the version number in `uses: leanprover/leanaction@v{VERSION}`. 34 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Lean Action - CI for Lean Projects" 2 | description: | 3 | Standard CI for Lean projects. 4 | Steps: 5 | - install elan 6 | - get Mathlib cache (optional, must be downstream of Mathlib) 7 | - lake build 8 | - lake test (optional) 9 | - lake exe runLinter (optional, must be downstream of Batteries) 10 | - check reservoir eligibility (optional) 11 | - check environment with lean4checker (optional) 12 | inputs: 13 | auto-config: 14 | description: | 15 | Automatically configure `lean-action` based on the Lake workspace. 16 | When set to "true", `lean-action` will use the Lake workspace to determine 17 | the set of features to run on the repository, such as `lake build` and `lake test`. 18 | Even when set to "true", the user can still override the auto configuration 19 | with the `build` and `test` inputs. 20 | Allowed values: "true" or "false". 21 | required: false 22 | default: "true" 23 | build: 24 | description: | 25 | Run `lake build`. 26 | Note, this input takes precedence over `auto-config`. 27 | Allowed values: "true" | "false" | "default". 28 | required: false 29 | default: "default" 30 | test: 31 | description: | 32 | Run `lake test`. 33 | Note, this input takes precedence over `auto-config`. 34 | Allowed values: "true" | "false" | "default". 35 | required: false 36 | default: "default" 37 | lint: 38 | description: | 39 | Run `lake lint`. 40 | Note, this input takes precedence over `auto-config`. 41 | Allowed values: "true" | "false" | "default". 42 | required: false 43 | default: "default" 44 | build-args: 45 | description: | 46 | Build arguments to pass to `lake build {build-args}`. 47 | For example, `build-args: "--quiet"` will run `lake build --quiet`. 48 | By default, `lean-action` calls `lake build` with no arguments. 49 | required: false 50 | default: "" 51 | use-mathlib-cache: 52 | description: | 53 | By default, `lean-action` attempts to automatically detect a Mathlib dependency and run `lake exe cache get` accordingly. 54 | Setting `use-mathlib-cache` will override automatic detection and run (or not run) `lake exe cache get`. 55 | Project must be downstream of Mathlib to use the Mathlib cache. 56 | Allowed values: "true" | "false" | "auto". 57 | required: false 58 | default: "auto" 59 | check-reservoir-eligibility: 60 | description: | 61 | Check if the repository is eligible for the Reservoir. 62 | Allowed values: "true" | "false". 63 | required: false 64 | default: "false" 65 | lean4checker: 66 | description: | 67 | Check environment with lean4checker. 68 | Lean version must be 4.8 or higher. 69 | The version of lean4checker is automatically detected using `lean-toolchain`. 70 | Allowed values: "true" | "false". 71 | required: false 72 | default: "false" 73 | use-github-cache: 74 | description: | 75 | Enable GitHub caching. 76 | Allowed values: "true" or "false". 77 | If use-github-cache input is not provided, `lean-action` will use GitHub caching by default. 78 | required: false 79 | default: "true" 80 | lake-package-directory: 81 | description: | 82 | The directory where `lean-action` will look for a Lake package and run `lake build`, etc. 83 | Allowed values: a valid directory containing a Lake package. 84 | If lake-package-directory is not provided, `lean-action` will use the root directory of the repository by default. 85 | required: false 86 | default: "." 87 | reinstall-transient-toolchain: 88 | description: | 89 | When the `lean-toolchain` file specifies a `lean-pr-release` toolchain, uninstall it before running any `lake` commands. 90 | This ensures the latest build of the toolchain will be downloaded and used to run CI steps. 91 | Allowed values: "true" | "false". 92 | required: false 93 | default: "false" 94 | outputs: 95 | build-status: 96 | description: | 97 | The status of the `lake build` step. 98 | Allowed values: "SUCCESS" | "FAILURE" | "". 99 | value: ${{ steps.build.outputs.build-status }} 100 | test-status: 101 | description: | 102 | The status of the `lake test` step. 103 | Allowed values: "SUCCESS" | "FAILURE" | "". 104 | value: ${{ steps.test.outputs.test-status }} 105 | lint-status: 106 | description: | 107 | The status of the `lake lint` step. 108 | Allowed values: "SUCCESS" | "FAILURE" | "". 109 | value: ${{ steps.lint.outputs.lint-status }} 110 | detected-mathlib: 111 | description: | 112 | If lean-action detected a mathlib dependency equals "true" 113 | otherwise equals "false". 114 | value: ${{ steps.detect-mathlib.outputs.detected-mathlib }} 115 | 116 | runs: 117 | using: "composite" 118 | steps: 119 | - name: install elan 120 | run: | 121 | : Install Elan 122 | ${GITHUB_ACTION_PATH}/scripts/install_elan.sh 123 | shell: bash 124 | working-directory: ${{ inputs.lake-package-directory }} 125 | 126 | - name: configure `lean-action` 127 | id: config 128 | env: 129 | AUTO_CONFIG: ${{ inputs.auto-config }} 130 | BUILD: ${{ inputs.build }} 131 | TEST: ${{ inputs.test }} 132 | LINT: ${{ inputs.lint }} 133 | run: | 134 | : Configure Lean Action 135 | ${GITHUB_ACTION_PATH}/scripts/config.sh 136 | shell: bash 137 | working-directory: ${{ inputs.lake-package-directory }} 138 | 139 | - name: reinstall transient toolchain 140 | if: ${{ inputs.reinstall-transient-toolchain == 'true' }} 141 | run: | 142 | : Reinstall Transient Toolchains 143 | if [[ "$(cat lean-toolchain)" =~ ^leanprover/lean4-pr-releases:pr-release-[0-9]+$ ]]; then 144 | printf 'Uninstalling transient toolchain %s\n' "$(cat lean-toolchain)" 145 | elan toolchain uninstall "$(cat lean-toolchain)" 146 | fi 147 | shell: bash 148 | working-directory: ${{ inputs.lake-package-directory }} 149 | 150 | - uses: actions/cache/restore@v4 151 | if: ${{ inputs.use-github-cache == 'true' }} 152 | with: 153 | path: ${{ inputs.lake-package-directory }}/.lake 154 | # cache key includes the operating system, the architecture (X86, X64, ARM, ARM64), the Lake manifest, and the git commit hash 155 | key: lake-${{ runner.os }}-${{ runner.arch}}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }} 156 | # if no cache hit, fall back to the cache from previous commit 157 | restore-keys: lake-${{ runner.os }}-${{ runner.arch}}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }} 158 | 159 | - name: detect mathlib 160 | # only detect Mathlib if the user did not provide the mathlib-cache input 161 | if: ${{ inputs.use-mathlib-cache == 'auto' }} 162 | id: detect-mathlib 163 | run: | 164 | : Detect Mathlib 165 | ${GITHUB_ACTION_PATH}/scripts/detect_mathlib.sh 166 | shell: bash 167 | working-directory: ${{ inputs.lake-package-directory }} 168 | 169 | - name: get mathlib cache 170 | # only get the cache if Mathlib was detected by detect-mathlib step or if the user explicitly set mathlib-cache to true 171 | if: ${{ steps.detect-mathlib.outputs.detected-mathlib == 'true' || inputs.use-mathlib-cache == 'true' }} 172 | run: | 173 | : Get Mathlib Cache 174 | echo "::group::Mathlib Cache" 175 | lake exe cache get 176 | echo "::endgroup::" 177 | echo 178 | shell: bash 179 | working-directory: ${{ inputs.lake-package-directory }} 180 | 181 | - name: build ${{ github.repository }} 182 | id: build 183 | if: ${{ steps.config.outputs.run-lake-build == 'true'}} 184 | env: 185 | BUILD_ARGS: ${{ inputs.build-args }} 186 | run: | 187 | : Lake Build 188 | ${GITHUB_ACTION_PATH}/scripts/lake_build.sh 189 | shell: bash 190 | working-directory: ${{ inputs.lake-package-directory }} 191 | 192 | - uses: actions/cache/save@v4 193 | if: ${{ inputs.use-github-cache == 'true' }} 194 | with: 195 | path: ${{ inputs.lake-package-directory }}/.lake 196 | key: lake-${{ runner.os }}-${{ runner.arch}}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }} 197 | 198 | - name: test ${{ github.repository }} 199 | id: test 200 | if: ${{ steps.config.outputs.run-lake-test == 'true'}} 201 | run: | 202 | : Lake Test 203 | ${GITHUB_ACTION_PATH}/scripts/lake_test.sh 204 | shell: bash 205 | working-directory: ${{ inputs.lake-package-directory }} 206 | 207 | - name: lint ${{ github.repository }} 208 | id: lint 209 | # only run linter if the user provided a module to lint 210 | if: ${{ steps.config.outputs.run-lake-lint == 'true'}} 211 | run: | 212 | : Lake Lint 213 | ${GITHUB_ACTION_PATH}/scripts/lake_lint.sh 214 | shell: bash 215 | working-directory: ${{ inputs.lake-package-directory }} 216 | 217 | - name: check reservoir eligibility 218 | if: ${{ inputs.check-reservoir-eligibility == 'true' }} 219 | # Passes in the private status, number of stars, and license id of the repository to check_reservoir_eligibility.sh script 220 | run: | 221 | : Check Reservoir Eligibility 222 | ${GITHUB_ACTION_PATH}/scripts/check_reservoir_eligibility.sh \ 223 | "${{ github.event.repository.private }}"\ 224 | "${{ github.event.repository.stargazers_count }}"\ 225 | "${{ github.event.repository.license.spdx_id }}" 226 | shell: bash 227 | working-directory: ${{ inputs.lake-package-directory }} 228 | 229 | - name: check environment with lean4checker 230 | if: ${{ inputs.lean4checker == 'true' }} 231 | run: | 232 | : Check Environment with lean4checker 233 | ${GITHUB_ACTION_PATH}/scripts/run_lean4checker.sh 234 | shell: bash 235 | working-directory: ${{ inputs.lake-package-directory }} 236 | -------------------------------------------------------------------------------- /scripts/check_reservoir_eligibility.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Group logging using the ::group:: workflow command 4 | echo "::group::Reservoir Eligibility Check Output" 5 | 6 | # Assign the arguments from github action to named variables 7 | private=$1 8 | number_of_stars=$2 9 | license_id=$3 10 | 11 | # Initialize exit code 12 | exit_code=0 13 | 14 | # Function to check if the license_id is a valid SPDX license 15 | function check_license() { 16 | local id=$1 17 | SPDX_DATA_URL="https://raw.githubusercontent.com/spdx/license-list-data/main/json/licenses.json" 18 | 19 | # Fetch the SPDX license list and filter by licenseId and isOsiApproved 20 | license=$(curl -s "$SPDX_DATA_URL" | jq -r --arg id "$id" '.licenses[] | select(.licenseId == $id and .isOsiApproved == true)') 21 | if [ -n "$license" ]; then 22 | return 0 23 | else 24 | # Return 1 if the license_id is not a valid SPDX license 25 | return 1 26 | fi 27 | } 28 | 29 | # Check if the license_id is a valid SPDX license and assign exit code 30 | if ! check_license "$license_id"; then 31 | echo "Package is ineligible for Reservoir because the repository does not contain a valid SPDX license." 32 | exit_code=1 33 | fi 34 | 35 | # Check for lake-manifest.json file 36 | if [ ! -f "lake-manifest.json" ]; then 37 | echo "Package is ineligible for Reservoir because the repository does not contain a lake-manifest.json file." 38 | exit_code=1 39 | fi 40 | 41 | # Check if the repository is private 42 | if [ "$private" == "true" ]; then 43 | echo "Package is ineligible for Reservoir because the repository is private." 44 | exit_code=1 45 | fi 46 | 47 | # Check if the repository has less than 2 stars 48 | if [ "$number_of_stars" -lt 2 ]; then 49 | echo "Package is ineligible for Reservoir because the repository has less than 2 stars." 50 | exit_code=1 51 | fi 52 | 53 | if [ $exit_code -eq 0 ]; then 54 | echo "Package is eligible for Reservoir." 55 | fi 56 | 57 | echo "::endgroup::" 58 | echo 59 | exit $exit_code 60 | -------------------------------------------------------------------------------- /scripts/config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # start log group 5 | echo "::group::Configure lean-action" 6 | 7 | # Get the directory of the script to read the step summaries md files 8 | SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" 9 | 10 | # Verify that a lake-manifest.json exist 11 | if [ ! -f lake-manifest.json ]; then 12 | echo "::error::No lake-manifest.json found. Run lake update to generate manifest" 13 | echo "::error::Exiting with status 1" 14 | exit 1 15 | fi 16 | 17 | # If the user specifies `build: true`, then run `lake build`. 18 | if [ "$BUILD" = "true" ]; then 19 | echo "build: true -> will run lake build" 20 | run_lake_build="true" 21 | fi 22 | 23 | # If the user specifies `test: true` 24 | if [ "$TEST" = "true" ]; then 25 | echo "test: true" 26 | # only run `lake test` if `lake check-test` returns true 27 | if ! lake check-test; then 28 | echo "lake check-test failed -> exiting with status 1" 29 | echo "::error::lake check-test failed: could not find a test runner" 30 | cat "$SCRIPT_DIR"/step_summaries/lake_check_error.md >>"$GITHUB_STEP_SUMMARY" 31 | exit 1 32 | else 33 | echo "lake check-test succeeded -> will run lake test" 34 | run_lake_test="true" 35 | fi 36 | fi 37 | 38 | # If the user specifies `lint: true` 39 | if [ "$LINT" = "true" ]; then 40 | echo "lint: true" 41 | # only run `lake lint` if `lake check-lint` returns true 42 | if ! lake check-lint; then 43 | echo "lake check-lint failed -> exiting with status 1" 44 | echo "::error::lake check-lint failed: could not find a lint driver" 45 | exit 1 46 | else 47 | echo "lake check-lint succeeded -> will run lake lint" 48 | run_lake_lint="true" 49 | fi 50 | fi 51 | 52 | if [ "$AUTO_CONFIG" = "true" ]; then 53 | if [ "$BUILD" = "false" ]; then 54 | # If the user specifies `build: false`, then do not run `lake build`. 55 | echo "build: false -> will not run lake build" 56 | run_lake_build="false" 57 | else 58 | # `build` input is not `false` and `auto-config: true` 59 | echo "auto-config: true" 60 | echo " -> will run lake build" 61 | run_lake_build="true" 62 | fi 63 | 64 | if [ "$TEST" = "false" ]; then 65 | # If the user specifies `test: false`, then do not run `lake test`. 66 | echo "test: false -> will not run lake test" 67 | run_lake_test="false" 68 | elif lake check-test; then 69 | # only run `lake test` with `auto-config: true` if `lake check-test` returns true 70 | echo "lake check-test succeeded -> will run lake test" 71 | run_lake_test="true" 72 | else 73 | echo "lake check-test failed -> will not run lake test" 74 | fi 75 | 76 | if [ "$LINT" = "false" ]; then 77 | # If the user specifies `lint: false`, then do not run `lake lint`. 78 | echo "lint: false -> will not run lake lint" 79 | run_lake_lint="false" 80 | elif lake check-lint; then 81 | # only run `lake lint` with `auto-config: true` if `lake check-lint` returns true 82 | echo "lake check-lint succeeded -> will run lake lint" 83 | run_lake_lint="true" 84 | else 85 | echo "lake check-lint failed -> will not run lake lint" 86 | fi 87 | fi 88 | 89 | # Set the `build`, `test`, and `lint` output parameters to be used to determine later steps 90 | { 91 | echo "run-lake-build=$run_lake_build" 92 | echo "run-lake-test=$run_lake_test" 93 | echo "run-lake-lint=$run_lake_lint" 94 | } >>"$GITHUB_OUTPUT" 95 | -------------------------------------------------------------------------------- /scripts/detect_mathlib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Group logging using the ::group:: workflow command 4 | echo "::group::Detect Mathlib Output" 5 | echo "Trying to detect if project is downstream of Mathlib." 6 | 7 | mathlib_repo_url="https://github.com/leanprover-community/mathlib4" 8 | # Check if lake-manifest.json contain the mathlib dependency pattern 9 | if [ -f lake-manifest.json ] && grep -q "$mathlib_repo_url" lake-manifest.json; then 10 | # Set the detected-mathlib variable to true and send it to the GitHub action output to be used in later steps 11 | echo "detected-mathlib=true" >>"$GITHUB_OUTPUT" 12 | echo "Detected Mathlib dependency in lake-manifest.json. Using Mathlib cache." 13 | else 14 | echo "detected-mathlib=false" >>"$GITHUB_OUTPUT" 15 | echo "Project is not downstream of Mathlib. Skipping Mathlib cache." 16 | fi 17 | 18 | echo "::endgroup::" 19 | echo 20 | -------------------------------------------------------------------------------- /scripts/install_elan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Group logging using the ::group:: workflow command 4 | echo "::group::Elan Installation Output" 5 | 6 | set -o pipefail 7 | curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | 8 | sh -s -- -y --default-toolchain none 9 | rm -f elan-init 10 | 11 | echo "$HOME/.elan/bin" >>"$GITHUB_PATH" 12 | "$HOME"/.elan/bin/lean --version 13 | "$HOME"/.elan/bin/lake --version 14 | 15 | echo "::endgroup::" 16 | echo 17 | -------------------------------------------------------------------------------- /scripts/lake_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # start log group 5 | echo "::group::Lake Build Output" 6 | 7 | # handle_exit function to handle the exit status of the script 8 | # and set the build-status output parameter accordingly 9 | handle_exit() { 10 | exit_status=$? 11 | if [ $exit_status -ne 0 ]; then 12 | echo "build-status=FAILURE" >>"$GITHUB_OUTPUT" 13 | echo "::error:: lake build failed" 14 | else 15 | echo "build-status=SUCCESS" >>"$GITHUB_OUTPUT" 16 | # end log group and add a new line to improve readabiltiy 17 | echo "::endgroup::" 18 | echo 19 | fi 20 | } 21 | 22 | trap handle_exit EXIT 23 | 24 | # use eval to ensure build arguments are expanded 25 | eval "lake build $BUILD_ARGS" 26 | -------------------------------------------------------------------------------- /scripts/lake_lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | echo "::group::Lake Lint Output" 5 | 6 | # handle_exit function to handle the exit status of the script 7 | # and set the lint-status output parameter accordingly 8 | handle_exit() { 9 | exit_status=$? 10 | if [ $exit_status -ne 0 ]; then 11 | echo "lint-status=FAILURE" >>"$GITHUB_OUTPUT" 12 | echo "::error:: lake lint failed" 13 | else 14 | echo "lint-status=SUCCESS" >>"$GITHUB_OUTPUT" 15 | echo "::endgroup::" 16 | echo 17 | fi 18 | } 19 | 20 | trap handle_exit EXIT 21 | 22 | lake lint 23 | -------------------------------------------------------------------------------- /scripts/lake_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | echo "::group::Lake Test Output" 5 | 6 | # handle_exit function to handle the exit status of the script 7 | # and set the test-status output parameter accordingly 8 | handle_exit() { 9 | exit_status=$? 10 | if [ $exit_status -ne 0 ]; then 11 | echo "test-status=FAILURE" >>"$GITHUB_OUTPUT" 12 | echo "::error:: lake test failed" 13 | else 14 | echo "test-status=SUCCESS" >>"$GITHUB_OUTPUT" 15 | echo "::endgroup::" 16 | fi 17 | } 18 | 19 | trap handle_exit EXIT 20 | 21 | lake test 22 | -------------------------------------------------------------------------------- /scripts/run_lean4checker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Group logging using the ::group:: workflow command 5 | echo "::group::lean4checker Output" 6 | echo "Checking environment with lean4checker" 7 | 8 | # clone lean4checker 9 | echo "Cloning and building lean4checker" 10 | git clone https://github.com/leanprover/lean4checker 11 | 12 | # build and test lean4checker in a subshell 13 | ( 14 | # detect toolchain version from lean-toolchain file 15 | # assumes toolchain is of the form ".*:{VERSION}" (e.g., "leanprover/lean4:v4.8.0-rc1") 16 | toolchain_version=$(< lean-toolchain cut -d: -f 2) 17 | echo "Detected toolchain version: $toolchain_version" 18 | 19 | # checkout version of lean4checker corresponding to toolchain version 20 | cd lean4checker || exit 21 | git config advice.detachedHead false # turn off git warning about detached head 22 | git checkout "$toolchain_version" 23 | cp ../lean-toolchain . 24 | 25 | # build lean4checker and test lean4checker 26 | lake build 27 | ./test.sh 28 | ) 29 | 30 | # run lean4checker 31 | echo "Running lean4checker" 32 | lake env lean4checker/.lake/build/bin/lean4checker 33 | 34 | echo "::endgroup::" 35 | echo 36 | -------------------------------------------------------------------------------- /scripts/set_output_parameters.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Group logging using the ::group:: workflow command 4 | echo "::group::Set Output Parameters" 5 | 6 | # If the BUILD_STATUS environment variable is not set, 7 | # set the `build-status` output parameter to NOT_RUN 8 | # Otherwise, set it to the output of the `lake build` step, i.e, the BUILD_STATUS environment variable 9 | if [ "$BUILD_STATUS" = "" ]; then 10 | echo "build-status=NOT_RUN" >>"$GITHUB_OUTPUT" 11 | else 12 | echo "build-status=$BUILD_STATUS" >>"$GITHUB_OUTPUT" 13 | fi 14 | 15 | # If the TEST_STATUS environment variable is not set, 16 | # set the `test-status` output parameter to NOT_RUN 17 | # Otherwise, set it to the output of the `lake test` step, i.e., the TEST_STATUS environment variable. 18 | if [ "$TEST_STATUS" = "" ]; then 19 | echo "test-status=NOT_RUN" >>"$GITHUB_OUTPUT" 20 | else 21 | echo "test-status=$TEST_STATUS" >>"$GITHUB_OUTPUT" 22 | fi 23 | 24 | # If the LINT_STATUS environment variable is not set, 25 | # set the `lint-status` output parameter to NOT_RUN 26 | # Otherwise, set it to the output of the `lake lint` step, i.e, the LINT_STATUS environment variable. 27 | if [ "$LINT_STATUS" = "" ]; then 28 | echo "lint-status=NOT_RUN" >>"$GITHUB_OUTPUT" 29 | else 30 | echo "lint-status=$LINT_STATUS" >>"$GITHUB_OUTPUT" 31 | fi 32 | 33 | echo "::endgroup::" 34 | -------------------------------------------------------------------------------- /scripts/step_summaries/lake_check_error.md: -------------------------------------------------------------------------------- 1 | ### `lake check-test` failed 2 | `lake check-test` could not find a test runner. Add script or lean_exe tagged `@[test_runner]` in the workspace's root package. --------------------------------------------------------------------------------