Unit tests pass locally but fail through GitHub Actions

Hi folks. I’ve put together a package for my Advent of Code. The unit tests pass locally but fail when run through my simple GitHub Actions workflow:

name: Run tests for AOC2021

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@latest
        with:
          version: 1.7
      - uses: julia-actions/julia-buildpkg@latest
        with: 
          project: "AOC2021"
      - uses: julia-actions/julia-runtest@latest
        with: 
          project: "AOC2021"

You’ll notice that the project is a subdirectory of the git repository.

The tests fail because Julia can’t find the submodules I use for each day, like Day01, which makes me think I’m misunderstanding how scoping works (something I often struggle with). The unit tests use imports like import AOC2021.Day06.part1, where part1 is a function of the submodule Day06.

When I run the unit tests locally, I do so by navigating to the parent directory and running julia --project=AOC2021 -e 'import Pkg;Pkg.test()' , which is similar to the command run by the GA workflow. There are no issues locally.

Can someone please help me identify what’s going wrong here?

1 Like

I’ve fixed it. The include in your main module used relative paths. Those paths didn’t work because the GitHub Action current directory was different from the current directory when running locally. I’ve sent in a pull request to your repository.

1 Like

Thank you so much @rikh! I’ve never seen absolute paths in include before. I don’t think I would have picked up on that without help. Thanks again.

1 Like

Good that you asked! The problem was probably the part where isfile was checked. That part couldn’t figure out the relative path correctly so gave zero files to include. Anyway, it’s solved now :+1: Your welcome

1 Like