Troubles setting up workflow in Github Actions

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:

  - linux
language: generic
sudo: required
dist: trusty
  - if [ $TRAVIS_OS_NAME = linux ]; then
      eval "$(curl -sL";
  - ... FoundationDB installation ...
  - swift test

I tried to port it to Github workflow:

name: FDBSwift

    - master

    runs-on: ubuntu-latest
    - uses: actions/checkout@v1
    - name: Install swiftenv
      run: eval "$(curl -sL"
    - name: Install FoundationDB
      run: ... FoundationDB installation ...
    - name: Run tests
      run: swift test

but when I triggered the check, I got an error swift: command not found as if step Run tests lost context.

Eventually I got working when I just squeezed all prep work into one step along with swift test, but it feels wrong.

Apparently I'm missing something, but official documentation isn't very friendly. Can anyone please help me with this?

You need to install swift or using an os with swift like macos.

Because swiftenv is not swift.

Swiftenv does exactly that, please see my Travis config or working Github Actions config.

Can you share your github actions logs ?

Sure. Failed and succeeded. Also Travis one.

use swift official docker image instead:

        tag: ['5.0', '5.1']
    runs-on: ubuntu-latest
      image: swift:${{ matrix.tag }}
      - uses: actions/checkout@v1
      - run: 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?

If it doesn't install Swift, why putting all steps into one step works?

It does install Swift.

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.

There is also this action: which has worked well for me so far.

Swift 5.2 is now officially installed on Ubuntu runners. See this issue for discussion, as well as the Ubuntu virtual environment reference.