Fix coverage link, streamline env vars in CI#12971
Conversation
|
Thank you for the pull request, @ggetz! ✅ We can confirm we have a CLA on file for you. |
|
Wait to review; This needs an additional change. |
|
This is ready for review and the PR description is up-to-date. |
jjspace
left a comment
There was a problem hiding this comment.
Overall very nice, thanks @ggetz! Definitely much better and more robust than the quick change I recently made. Just had one comment that's really a question
CI seems to be passing and working as expected. I assume there's not really any way to test this locally?
| - name: set status pending | ||
| if: ${{ env.AWS_ACCESS_KEY_ID != '' }} | ||
| run: | | ||
| npx @dotenvx/dotenvx run -f ./.github/workflows/.env.pull_request -- \ |
There was a problem hiding this comment.
Why are we calling dotenvx from npx instead of using it directly in the script files? is it just so we can specify the extra .env.pull_request files?
Also as an aside for my curiosity, what is the reason you went with dotenvx instead of just dotenv? a quick search seems that the motivation would be to encrypt the env files with secrets but we aren't doing that. Is this future proofing?
There was a problem hiding this comment.
I chose dotenvx specifically because it supports variable expansion and command substitution, which I don't believe "regular" dotenv supports.
There was a problem hiding this comment.
Why are we calling dotenvx from npx instead of using it directly in the script files? is it just so we can specify the extra .env.pull_request files?
Yes. The default .env is being loaded from the script itself, but this command is what allows us to override with the CI-specific values in .env.pull_request. If there's an alternative syntax you know of, please tell!
There was a problem hiding this comment.
I think my expectation is from using older versions of dotenv. I was used to the paradigm of always only including the package and configuring it in the file it's used in. It looks like this is still an option using dotenvx.config([path]). However I don't think this allows for the command line level variable substitution which it seems we need.
I think it's just kinda confusing not knowing where and when things are defined, especially when the commands are different in CI. I think I get it now but it's a bit weird.
For example, this command only uses -f ./.github/workflows/.env.pull_request because the setCommitStatus.js script imports @dotenvx/dotenvx/config to setup the "base" .env however the command lower in this file requires -f ./.github/workflows/.env.pull_request -f .env in order to include both.
Plus my other comment about not always being included could lead to devs getting confused why process.env vars are set up one way in some files but missing in others if they forget an import or to run the command wrapped with dotenvx run
Co-authored-by: jjspace <8007967+jjspace@users.noreply.github.com>
No, not end-to-end. You could test some commands locally, but if CI is working as expected I think that's unnecessary. |
|
@jjspace Could you take a final pass on this PR and merge if happy? I think this addresses the rogue coverage artifacts you mentioned seeing. |
jjspace
left a comment
There was a problem hiding this comment.
Overall I still think this is a good change. Just a few more comments/discussion around dotenvx
I also merged in main which I think still captures all the changes even though we broke apart the gulpfile some since this was first opened
| @@ -0,0 +1,132 @@ | |||
| import yargs from "yargs"; | |||
| import { hideBin } from "yargs/helpers"; | |||
| import "@dotenvx/dotenvx/config"; | |||
There was a problem hiding this comment.
Should this be imported in the gulpfile and all our scripts?
Alternatively should all our package.json scripts be prefixed with dotenvx run?
| - name: set status pending | ||
| if: ${{ env.AWS_ACCESS_KEY_ID != '' }} | ||
| run: | | ||
| npx @dotenvx/dotenvx run -f ./.github/workflows/.env.pull_request -- \ |
There was a problem hiding this comment.
I think my expectation is from using older versions of dotenv. I was used to the paradigm of always only including the package and configuring it in the file it's used in. It looks like this is still an option using dotenvx.config([path]). However I don't think this allows for the command line level variable substitution which it seems we need.
I think it's just kinda confusing not knowing where and when things are defined, especially when the commands are different in CI. I think I get it now but it's a bit weird.
For example, this command only uses -f ./.github/workflows/.env.pull_request because the setCommitStatus.js script imports @dotenvx/dotenvx/config to setup the "base" .env however the command lower in this file requires -f ./.github/workflows/.env.pull_request -f .env in order to include both.
Plus my other comment about not always being included could lead to devs getting confused why process.env vars are set up one way in some files but missing in others if they forget an import or to run the command wrapped with dotenvx run
| node-version: "22" | ||
| - name: npm install | ||
| run: npm install | ||
| - name: set status pending |
There was a problem hiding this comment.
What if these jobs fail? Do these pending statuses time out or fail automatically? I see we have a section at the end to set them to success but does the failure state have to be manual?
In the previous version the statuses weren't even created until it was successful.
Description
TLDR; This PR should fix the link to coverage results in GitHub PRs, but more broadly, does some housekeeping of our deploy and status scripts.
Mismatched environment variables
Between incremental updates and migrating between various services and tools, our build and deploy scripts have become quite sprawling. Some things also fall through the cracks, like the broken test coverage link in the CI checks, but we're also dragging along patterns that are no longer serving us. This PR does not fix everything, but attempts to consolidate and cleanup some of these CI/CD related things.
I noticed when reviewing #12957 that there are several misconfigured environment variables in the
devworkflow as opposed to thedeployworkflow where most other build artifacts are uploaded. Mis-matches across the workflows were ultimately resulting in broken links.pull_requesthook, the GitHubref_nameis different than the branch name. This ended up using different versions of "DEPLOYED_URL" leading to a broken link.pull_requesttriggers, the value ofCOMMIT_SHAwill the merge commit.Change summary
envproperties.setDeployStatusscript out ofgulpfile.jsas it is unrelated to the build processes—It is now a standalone node script with command line help docs.setCommitStatus. For flexibility, the command itself is more granular so it can be run per-artifact and per-status update. This allows check updates to run separately in different tasks or workflows as needed.deploySetVersionscript out ofgulpfile.jsin favor of thenpm versioncli command which we use for our release processes.package.jsonand the corresponding build guide..envfiles in which can configure common environment variables as described in the updated docs ofContinuousIntegration/README.mddotenvxas it allows us to variable expansion and simple command substitution.pushorpull_request. Sincepull_requestdoes not run in the context of the branch itself, we need to account for the available GitHub context to grab branch names and commit SHA's.CESIUM_VERSION, that detects the current package version making it more convenient to access across various contexts.Issue number and link
Fixes #11827
Testing plan
a. "coverage results" should navigate to the coverage results index
b. "cesium-.tgz" should download the packed npm package
c. "Cesium-.zip" should download the release zip
d. "index.html` should navigate to the deployed static build
Author checklist
CONTRIBUTORS.mdI have updatedCHANGES.mdwith a short summary of my changeI have added or updated unit tests to ensure consistent code coverage