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

refactor(ci): use GitHub variables for non-sensitive info #6357

Merged
merged 12 commits into from
Apr 13, 2023

Conversation

gustavovalverde
Copy link
Member

@gustavovalverde gustavovalverde commented Mar 20, 2023

Motivation

We've been using values that are variable across multiple workflows,
and those can only be changed if modifying the workflows, but we should
be able to change the values without committing new changes in the code
for this purpose we're now using GitHub Variables, and even moving
non-sensitive information into variables instead of secrets. Allowing
more flexibility and other scenarios that should be easier to manage,
like deploying to Mainnet or Testnet.

Closes: #6312

This will also make it easier to fix our actual main branch failures

Specifications

https://docs.github.com/en/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows

Solution

Use GitHub variables for:

  • Our GCP Project name
  • Our registry URLs
  • GCP machine types
  • Other variables that have an impact on all or most workflows

Review

Anyone from the DevOps team, after test are passing (or before for desing feedback)

Check the actual values here: https://github.com/ZcashFoundation/zebra/settings/variables/actions

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

We've been using values that are variable across multiple workflows,
and those can only be changed if modifying the workflows, but we should
be able to change the values without committing new changes in the code
for this purpose we're now using GitHub Variables, and even moving
non-sensitive information into variables instead of secrets. Allowing
more flexibility and other scenarios that should be easier to manage,
like deploying to Mainnet or Testnet.
@github-actions github-actions bot added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Mar 20, 2023
@codecov
Copy link

codecov bot commented Mar 20, 2023

Codecov Report

Merging #6357 (5534c74) into main (403c074) will decrease coverage by 0.25%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6357      +/-   ##
==========================================
- Coverage   77.90%   77.66%   -0.25%     
==========================================
  Files         304      304              
  Lines       39665    39665              
==========================================
- Hits        30902    30806      -96     
- Misses       8763     8859      +96     

@gustavovalverde gustavovalverde self-assigned this Mar 20, 2023
@gustavovalverde gustavovalverde added A-devops Area: Pipelines, CI/CD and Dockerfiles C-enhancement Category: This is an improvement P-High 🔥 I-integration-fail Continuous integration fails, including build and test failures labels Mar 20, 2023
@gustavovalverde gustavovalverde marked this pull request as ready for review March 20, 2023 22:58
@gustavovalverde gustavovalverde requested a review from a team as a code owner March 20, 2023 22:58
@gustavovalverde gustavovalverde requested review from dconnolly and removed request for a team March 20, 2023 22:58
@gustavovalverde
Copy link
Member Author

This should also make it easier to fix main branch CI failures, when related to CPUs not being available on a specific region.

@gustavovalverde gustavovalverde changed the title refactor(ci): use GitHub secrets and variables refactor(ci): use GitHub variables for non-sensitive info Mar 21, 2023
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change, I think it will make things a lot easier!

But I'm not sure how to review or test it, since we only run some workflows on main or on specific events (like releases).

@teor2345
Copy link
Contributor

This is probably something for the next refactor, but can you change some of the secrets that don't need to be confidential into variables?

it's much easier to edit the value if we know what the previous value was.

@mpguerra
Copy link
Contributor

This is probably something for the next refactor, but can you change some of the secrets that don't need to be confidential into variables?

it's much easier to edit the value if we know what the previous value was.

Can this be merged "as is" with follow ups in other PRs? Otherwise this will have to be parked until Sprint 8

@teor2345
Copy link
Contributor

This is probably something for the next refactor, but can you change some of the secrets that don't need to be confidential into variables?
it's much easier to edit the value if we know what the previous value was.

Can this be merged "as is" with follow ups in other PRs? Otherwise this will have to be parked until Sprint 8

Unfortunately, this PR uses a single variable for the machine type, but our current CI uses two different machine types. Changing all workflows to a single machine type could break CI or be really expensive, so we need to fix that before we merge:
#6357 (comment)

@teor2345
Copy link
Contributor

All the other suggestions could be done as follow-ups.

@gustavovalverde
Copy link
Member Author

Aside from secrets.DOCKERHUB_USERNAME, all other non-sensitive information was replaced with a variable.

teor2345
teor2345 previously approved these changes Apr 12, 2023
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these fixes, it looks good!

mergify bot added a commit that referenced this pull request Apr 12, 2023
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR failed in the merge queue, because it tried to create a disk using the incorrect network name:

ERROR: (gcloud.compute.images.create) argument --labels: Bad value [Mainnet]: Only hyphens (-), underscores (_), lowercase characters, and numbers are allowed. International characters are allowed.

https://github.com/ZcashFoundation/zebra/actions/runs/4683572250/jobs/8299559492?pr=6493#step:13:81

I have applied a quick fix to use the correct network variable, and a fix for another incorrect network default variable.

In general, it would help if we put more details in variable names, so that it's clearer what they should be used for:

  • vars.ZCASH_NETWORK -> vars.DEFAULT_ZCASH_NETWORK
  • ${NETWORK} -> ${NETWORK_LOWERCASE}

(I didn't make these changes in this PR, happy to leave them to a later refactor.)

@teor2345 teor2345 removed the I-integration-fail Continuous integration fails, including build and test failures label Apr 13, 2023
@gustavovalverde
Copy link
Member Author

I have applied a quick fix to use the correct network variable, and a fix for another incorrect network default variable.

In general, it would help if we put more details in variable names, so that it's clearer what they should be used for:

vars.ZCASH_NETWORK -> vars.DEFAULT_ZCASH_NETWORK
${NETWORK} -> ${NETWORK_LOWERCASE}

Thanks for this, I'll take this into account for further refactors I have pending.

@teor2345
Copy link
Contributor

Failed in the merge queue due to #6498

@teor2345
Copy link
Contributor

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Apr 13, 2023

refresh

✅ Pull request refreshed

mergify bot added a commit that referenced this pull request Apr 13, 2023
@mergify mergify bot merged commit 455db91 into main Apr 13, 2023
@mergify mergify bot deleted the use-new-gcp-project branch April 13, 2023 06:56
@arya2 arya2 mentioned this pull request Apr 18, 2023
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles C-enhancement Category: This is an improvement C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(ci): define configuration variables for multiple workflows
3 participants