DeLaGuardo / setup-clojure

GitHub Action to provision clojure's most popular build tools for Linux, Mac OS X and Windows.
MIT License
184 stars 27 forks source link

Consider moving `pre` logic to the main entrypoint #66

Closed zharinov closed 2 years ago

zharinov commented 2 years ago

It seems like pre-action feature breaks GitHub actions composability. GitHub doesn't support YAML anchors feature that would decrease code duplication.

However, GitHub provides composite actions which are defined the similar way action.yml in this repo does, but instead of JavaScript code it depends on and runs another actions. You can think of it like higher-order action.

The problematic scenario is following:

  1. Define composite action in .github/actions/setup-clojure
name: 'Setup Clojure tooling'
description: 'Install Java, Clojure CLI and Babashka'
runs:
  using: "composite"
  steps:
    - uses: actions/setup-java@v3.4.1
      with:
        distribution: temurin
        java-version: 11

    - uses: DeLaGuardo/setup-clojure@9.3
      with:
        cli: latest
        lein: latest
        bb: latest

    - name: Package cache
      uses: actions/cache@v3.0.6
      with:
        path: |
          ~/.m2/repository
          ~/.gitlibs
          ~/.deps.clj
        key: cljdeps-${{ hashFiles('project.clj', 'deps.edn', 'bb.edn') }}
        restore-keys: cljdeps-
  1. Use it from the workflow file .github/workflows/test in the same repository
- steps:
  # Essential if you're using locally-defined action
  - name: Checkout
    uses: actions/checkout@v3.0.2

  - name: Setup Clojure tooling
    uses: ./github/actions/setup-clojure
  1. DeLaGuardo/setup-clojure@9.3 outputs warning and skips main entrypoint:
Warning: `pre` execution is not supported for local action from './.github/actions/setup-clojure'
  1. The entire workflow later fails with something like:
clojure: command not found