Skip to content
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

Inara image cannot be used with Gitlab CI #34

Open
platipodium opened this issue Apr 2, 2023 · 7 comments
Open

Inara image cannot be used with Gitlab CI #34

platipodium opened this issue Apr 2, 2023 · 7 comments

Comments

@platipodium
Copy link

Inara Docker image in CI pipeline fails with getopt: unrecognized option: c

Running with gitlab-runner 15.10.0-hifis0 (285ec021)
  on hifis-runner-manager-1 qSeqXZze, system ID: s_18a5a67640b5

Preparing the "docker+machine" executor
00:20
Using Docker executor with image openjournals/inara:latest ...
Pulling docker image openjournals/inara:latest ...
Using docker image sha256:a880d6aaa55fe9e8d7d0ffd102d531595ef3e5d8f219e0cb9dcb7bbc2bf3b317 for openjournals/inara:latest with digest openjournals/inara@sha256:86d957f2226bc8010e386180206144c2362fad02b3331ebe300cc1d6088131d9 ...

Preparing environment
00:01
Running on runner-qseqxzze-project-4399-concurrent-0 via runner-qseqxzze-hifis-autoscale-1680471447-19e9c35a...

Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/mussel/netlogo-northsea-species/.git/
Created fresh repository.
Checking out e085305e as detached HEAD (ref is main)...
Skipping Git submodules setup

Executing "step_script" stage of the job script
00:00
Using docker image sha256:a880d6aaa55fe9e8d7d0ffd102d531595ef3e5d8f219e0cb9dcb7bbc2bf3b317 for openjournals/inara:latest with digest openjournals/inara@sha256:86d957f2226bc8010e386180206144c2362fad02b3331ebe300cc1d6088131d9 ...
getopt: unrecognized option: c

Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
@tarleb
Copy link
Collaborator

tarleb commented Apr 3, 2023

Thanks for the report. I've updated the entryscript, so it will now reply with a more helpful message.

getopt: unrecognized option: c
Usage: /usr/local/bin/inara [OPTIONS] INPUT_FILE
Options:
        -l: create log files for all formats
        -m: article info file; YAML file contains article metadata
        -o: comma-separated list of output format; defaults to jats,pdf
        -p: flag to force the production of a publishing PDF
        -v: increase verbosity; can be given multiple times

@tarleb tarleb closed this as completed Apr 3, 2023
@platipodium
Copy link
Author

Curiously, I don't see how I would have set the option -c. Here the .gitlab-ci.yml section used to trigger the build (and fail)

joss-paper:
  stage: deploy
  image: 'openjournals/inara:latest'
  script:
    - inara -o pdf,cff doc/joss/paper.md
  variables:
    GIT_SHA: $CI_COMMIT_SHA
    JOURNAL: joss

So why do I get the unrecognised option -c error on the CI pipeline?

@zyzzyxdonta
Copy link

zyzzyxdonta commented May 4, 2023

I have the same problem. This is because the Docker image is not able to handle what is happening in GitLab CI. Before the user-provided before_script and script are run, GitLab CI tries to clone your repo into the container. The first option it passes to git is -c. You can reproduce this by running

docker run --rm openjournals/inara git -c

which gives the same result.

You can prevent this behaviour by setting the variable GIT_STRATEGY: none in your .gitlab-ci.yml. But then you will be missing the code for your paper as the repository is not cloned.

I would suggest reopening this issue and changing the title to reflect the actual problem: The container doesn't work with GitLab CI because you can not pass scripts to it; just arguments to the hard-coded program.

I think it would be quite valuable to have it working as GitLab is quite a common tool these days and is used in many research institutions, including the Helmholtz Association (for which both @platipodium and I, and thousands of other scientists work).

Thank you in advance!

@tarleb tarleb reopened this May 4, 2023
@tarleb tarleb changed the title getopt: unrecognized option: c Inara image cannot be used with Gitlab CI May 4, 2023
@tarleb
Copy link
Collaborator

tarleb commented May 4, 2023

Thank you for these details @zyzzyxdonta. One way to get around this might be to use the entrypoint option for containers. See, for example, https://gitlab.com/pandoc/pandoc-ci-example. You may have to install git first by running apk add git in the container.

We should definitely document this properly if you can get it working. For the benefit of future users running into similar issues.

@zyzzyxdonta
Copy link

zyzzyxdonta commented May 4, 2023

This is the first time I heard about the entrypoint option. 🙈 Thank you so much! Here is a working .gitlab-ci.yml:

inara:
  image:
    name: "openjournals/inara"
    entrypoint: ["/bin/sh", "-c"]
  before_script:
    - apk add git
  script:
    - /usr/local/bin/inara paper.md
  artifacts:
    paths:
      - paper.*

Let me know if you want me to try anything else for the documentation.

@platipodium
Copy link
Author

Thanks for the hints above, I also got it to work with entrypoint, does not seem to need git. Here's the production version from my .gitlab-ci.yml FYR:

joss-inara:
  stage: deploy
  image:
    name: openjournals/inara
    entrypoint: ["/bin/sh", "-c"]
  variables:
    GIT_SHA: $CI_COMMIT_SHA
    JOURNAL: joss
  script:
    - echo "Calling inara -o pdf,cff doc/joss/paper.md" 
    - inara -o pdf,cff doc/joss/paper.md
  artifacts:
    paths:
      - ./doc/joss/paper.pdf
      - ./doc/joss/CITATION.cff
  needs: []

@tarleb
Copy link
Collaborator

tarleb commented May 4, 2023

Thank you! Pinging @IlonaSilverwood who's the resident documentation wizard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants