-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core.getInput treats YAML booleans as strings #361
Comments
You can use a pattern like Workflow uses yaml 1.2 so all the yaml 1.1 boolean values are intentionally not supported. |
@ericsciple please also see my response on the PR I submitted. I don't see why the implementation detail of passing env vars should be of concern to the consuming code. The values are defined in a format that supports non-string scalar types, so I expect those types to be available in the consuming code. Is there anywhere this design decision is documented? |
The whole API is very-very badly written and designed. I would highly recommend to find out Typescript / Javascript expert in your team (I think @JasonEtco is that guy) to do that from scratch. Otherwise you have to spend years to fix up GitHub Actions on top of that errorneous foundation. I started writing my own action and struggle with that decision every minute. The whole idea of GitHub Actions is awesome, but developing experience not so much. I wanted to write action to setup React Native on top of @actions/setup-java action. And what I found out. Actions are not composableI can't call other action from my own action. React Native requires Java to be already installed. jobs:
build:
name: Build library
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Java environment
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Setup React Native environment
uses: actions/setup-react-native@v1
with:
version: 0.63.2 But it's not possible in actions/setup-react-native to know whether Java was installed or not (in safe and reliable way). I have to check whether Either I have to add other input parameter jobs:
build:
name: Build library
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- id: set-java
name: Setup Java environment
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Setup React Native environment
uses: actions/setup-react-native@v1
with:
java_installation_path: ${{ steps.set-java.outputs.path }} // Provide manually Or I have to guess about what actions/setup-java has changed in global state or know it's internal implementation - know that Questions:
Action's API is not type-safeQuestions:
Not using all advancements of Javascript ecosystem of 2020Questions:
You coud use these libraries:
You could use https://pnpm.js.org package manager which stores only one package for whole filesystem (and use could cache this directory, making package installations instant). Yes, using symlinks it installs only one version of package in ~/.pnpm-store and makes symlinks to these packages. This greatly reduces required space and improves installation speed. Now actions are just a bunch of scripts exactly like bash, but using javascript. Every function mutates global state (for example in @actions/setup-java implementation), it's not possible to call them safely without side-effects. I can't reuse your code in @actions/setup-java because every call of every functon changes something in virtual machine (set up new environment variable / modifies PATH / do something with filesystem) Law and License violationsAccording to MIT License (and Apache License has similar clause too) it's prohibited to provide / publish code without LICENSE / NOTICE file. It's a direct license violation. Excerpt from MIT License:
Whenever you (and actions's developers too) use any npm package (under MIT / Apache license) license of that package shall be provided into execution environment (if State of the Art of Docker and GitHub ActionWhen it comes to current situation there is even problems when one action executed multiple times (due to global state modification) actions/setup-java#44. All these problems will grow as snpwball. But at the same time you use advanced technologies (not utilizing full their power) like containers / layered filesystem https://docs.docker.com/storage/storagedriver SolutionsJavascript Ecosystem:
GitHub Actions:
Real Use CasesLe't look at real bug and try to solve them with new architecture. actions/setup-java#44 action could look like thisjobs:
build:
name: Install multiple JDKs
runs-on: ubuntu-20.04
steps:
- name: Setup Java 8
// Setup JAVA_HOME and installs java into /usr/share/java
uses: actions/setup-java@v1
with:
java-version: 8
// Allow to save modifications into filesystem
commit: true
- name: Setup Java 9
// **Same action** setup JAVA_HOME and installs java into /usr/share/java
uses: actions/setup-java@v1
with:
java-version: 9
// Inspect **announced** changes; add is a special command
// set value on JAVA_HOME into JAVA_9_HOME
// usual Javascript function call
commit: setEnvironmentVariable('JAVA_9_HOME', after.step.env.changed['JAVA_HOME'])
// rename and move installed and unziped Java package into another location
// if we don't know changed paths we can always inspect them beforehand
commit: moveToDirectory('/usr/share/java9', after.step.path.changed['/usr/share/java'])
// append to PATH changes made in step
commit: appenToPath(extractPathDifference(before.step.env, after.step.env.changed['PATH'])) All hevy lifting job was done by action What we did is just some tweaks to action - changed PATH, and renamed bundle location, put action's default JAVA_HOME under JAVA_8_HOME. Only these changes will be applied. If action did anything else (saved downloaded file, downloaded another files, changed other environment variables) - all these changes will be lost. |
We should focus this issue and scope discussions to the boolean question at hand. Much of the other work mentioned here like using packages to distribute, composing actions is on the services backlog and beyond the scope of just the toolkit. Happy to discuss and / or route other issues raised as separate issues. |
GitHub Actions does not support boolean inputs in yaml files yet. See: actions/toolkit#361
all inputs are strings even though their yaml definition suggests that they may of other types too. see actions/toolkit#361
You can now retrieve boolean values via This will be released shortly |
|
Describe the bug
When I try to use a boolean value in my
action.yaml
file or workflow definition and retrieve it usingcore.getInput
the result is a string.To Reproduce
Steps to reproduce the behavior:
gh-action-boolean-input-repro
> Bug repro'Run /./
Expected behavior
No error is thrown, the input is interpreted as a boolean
The text was updated successfully, but these errors were encountered: