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

internal/ci: reading from unset environment variable in GitHub workflow does not result in an error #3603

Open
myitcv opened this issue Nov 28, 2024 · 2 comments

Comments

@myitcv
Copy link
Member

myitcv commented Nov 28, 2024

What version of CUE are you using (cue version)?

$ cue version
cue version v0.0.0-20241128110049-c9d519e55269

go version go1.23.2
      -buildmode exe
       -compiler gc
  DefaultGODEBUG asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
     CGO_ENABLED 1
          GOARCH arm64
            GOOS linux
         GOARM64 v8.0
             vcs git
    vcs.revision c9d519e55269223c51cde19469cb7978f9777282
        vcs.time 2024-11-28T11:00:49Z
    vcs.modified false
cue.lang.version v0.12.0

Does this issue reproduce with the latest release?

Not a CUE issue, but the problem is present in the CI config at c9d519e

What did you do?

In run https://github.com/cue-lang/cue-trybot/actions/runs/12066599935/job/33648939405, a read from $CUE_LOGINS to populate $CUE_CONFIG_DIR/logins.json essentially failed because that environment variable was unset, and we ended up with an empty file.

This happened because the trybot run in question was against https://review.gerrithub.io/c/cue-lang/cue/+/1204109/8, a commit which had a merge base against origin/master of a point before https://review.gerrithub.io/c/cue-lang/cue/+/1204254 landed. CL 1204254 moved us away from CUE_LOGINS with a follow-up of that environment variable being unset in the GitHub secrets environment. Hence the attempt to read from $CUE_LOGINS should have failed, but didn't.

What did you expect to see?

A failure in CI at the point of trying to read from $CUE_LOGINS

What did you see instead?

A subsequent failure which made it hard to diagnose the root cause.

Not sure if there is a way that we can make all script-based steps run with set -u equivalent. See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#defaultsrunshell for reference.

@mvdan
Copy link
Member

mvdan commented Nov 28, 2024

set -u is short for set -o nounset, so that's the full name of the option for the sake of searching the internet.

Unfortunately, "github actions nounset" does not seem to yield any useful Google results. I'm also not sure that there is a way to enforce this for our choice of bash as a shell on entire workflows or jobs, short of some relatively hacky templating across all job steps to inject a set -o nounset line before every run script when the shell is bash.

@myitcv
Copy link
Member Author

myitcv commented Dec 8, 2024

In a quick hack, I had a go at fixing this for the vscode-cue repo in https://review.gerrithub.io/c/cue-lang/vscode-cue/+/1205357

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

No branches or pull requests

2 participants