So I've been experimenting with new Github Actions, and tried to setup a workflow for running tests in linux environment. I already have a perfectly working Travis config which utilizes swiftenv tool:
os:
- linux
env:
language: generic
sudo: required
dist: trusty
install:
- if [ $TRAVIS_OS_NAME = linux ]; then
eval "$(curl -sL https://swiftenv.fuller.li/install.sh)";
fi
before_script:
- ... FoundationDB installation ...
script:
- swift test
You didn't get the original question :) I got it working eventually, but in a dirty and non-modular way. It should work without Docker (also I'm quite sure it runs inside Docker already), but for some reason context isn't saved between steps.
From what I see in your config files, you're actually never using swiftenv; you're just installing it. And installing it does not install swift.
So in the end you're just relying on pre-installed swift (if any). To make sure of that could you check result of swiftenv versions in both your config?
That is what is happening. Something about the install is not surviving into the next step.
I imagine it has to do with environment variables. swiftenv modifies them to point to its install, but if the next step uses a fresh environment, then it would appear to have vanished.
If you want to debug it, you could try printing the environment at the end of the install step and also at the beginning of the test step, so that you could compare the difference. Beware though, that there might also be security keys or the like in the environment that you could spill to the whole word in the process if you are not careful how you go about it. And unless you are part of the development team for GitHub Actions, you may not be able to actually fix it anyway.
Iâm now trying to set up Git actions too. I ran across this in the documentation, which likely explains what you see:
Each run keyword represents a new process and shell in the virtual environment. When you provide multi-line commands, each line runs in the same shell. For example:
A single-line command:
- name: Install Dependencies
run: npm install
A multi-line command:
- name: Clean install dependencies and build
run: |
npm ci
npm run build
The spawning of a new shell each time loses the environment, which appears to be deliberate on GitHubâs part. (Maybe it is to prevent multiple thirdâparty actions compromising one anotherâs security?)
However, as youâve figured out, their multiline syntax works, albeit without the clean division of results in the user interface.