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

tool: script to update the golang version #1283

Merged
merged 13 commits into from
Oct 22, 2024
Merged

Conversation

clamoriniere
Copy link
Collaborator

@clamoriniere clamoriniere commented Jul 10, 2024

What does this PR do?

Provide a script to safely update the golang version.
This script is taking the golang version in go.work file and path all the files that contain the golang version.

  • Add tooling to update golang version in all the places that it is
    defined.
  • Use the go ersion present in go.work to update the version everywhere.
  • Update the go.mod files to use the go workspace.
  • Fix some issues is the makefile
  • Add in the CI a job to verify that the golang version in properly sync
    everywhere.
  • this PR also add a CI job to verify that the golang version is properly up-to-date in each file.

Motivation

Simplify golang version update

Additional Notes

Anything else we should know when reviewing?

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

Write there any instructions and details you may have to test your PR.

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label

@clamoriniere clamoriniere added enhancement New feature or request tooling labels Jul 10, 2024
@clamoriniere clamoriniere added this to the v1.9.0 milestone Jul 10, 2024
@clamoriniere clamoriniere requested review from a team as code owners July 10, 2024 21:00
@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.70%. Comparing base (86c5b1d) to head (001dd2c).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1283   +/-   ##
=======================================
  Coverage   48.70%   48.70%           
=======================================
  Files         224      224           
  Lines       19852    19852           
=======================================
  Hits         9669     9669           
  Misses       9675     9675           
  Partials      508      508           
Flag Coverage Δ
unittests 48.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86c5b1d...001dd2c. Read the comment docs.

Copy link
Contributor

@buraizu buraizu left a comment

Choose a reason for hiding this comment

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

Thanks, approving with a minor update suggested per the documentation style guide

docs/how-to-contribute.md Outdated Show resolved Hide resolved
@clamoriniere clamoriniere force-pushed the clamoriniere/update-golang-auto branch from 6060b72 to 2aa3b92 Compare July 11, 2024 18:30
@khewonc khewonc modified the milestones: v1.9.0, v1.10.0 Sep 5, 2024
@clamoriniere clamoriniere force-pushed the clamoriniere/update-golang-auto branch 5 times, most recently from ac0a4f6 to e39fe54 Compare October 8, 2024 21:19
* Add tooling to update golang version in all the places that it is
defined.
* Use the go ersion present in go.work to update the version everywhere.
* Update the go.mod files to use the go workspace.
* Fix some issues is the makefile
* Add in the CI a job to verify that the golang version in properly sync
  everywhere.
@clamoriniere clamoriniere force-pushed the clamoriniere/update-golang-auto branch from e39fe54 to 9394316 Compare October 8, 2024 22:15
@levan-m levan-m force-pushed the clamoriniere/update-golang-auto branch 4 times, most recently from db5d75c to ad0c415 Compare October 11, 2024 01:08
@levan-m levan-m force-pushed the clamoriniere/update-golang-auto branch from ad0c415 to cd57616 Compare October 11, 2024 01:33
files: cover.out,cover_integration_v1.out,cover_integration_v2.out
flags: unittests
- name: Set up Go
uses: actions/setup-go@v1

Choose a reason for hiding this comment

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

🟠 Code Vulnerability

Workflow depends on a GitHub actions pinned by tag (...read more)

When using a third party action, one needs to provide its GitHub path (owner/project) and can eventually pin it to a Git ref (a branch name, a Git tag, or a commit hash).

No pinned Git ref means the action uses the latest commit of the default branch each time it runs, eventually running newer versions of the code that were not audited by Datadog. Specifying a Git tag is better, but since they are not immutable, using a full length hash is recommended to make sure the action content is actually frozen to some reviewed state.

Be careful however, as even pinning an action by hash can be circumvented by attackers still. For instance, if an action relies on a Docker image which is itself not pinned to a digest, it becomes possible to alter its behaviour through the Docker image without actually changing its hash. You can learn more about this kind of attacks in Unpinnable Actions: How Malicious Code Can Sneak into Your GitHub Actions Workflows. Pinning actions by hash is still a good first line of defense against supply chain attacks.

Additionally, pinning by hash or tag means the action won’t benefit from newer version updates if any, including eventual security patches. Make sure to regularly check if newer versions for an action you use are available. For actions coming from a very trustworthy source, it can make sense to use a laxer pinning policy to benefit from updates as soon as possible.

View in Datadog  Leave us feedback  Documentation

go-version: ${{ env.GO_VERSION }}
id: go
- name: install required packages
uses: mstksg/get-package@v1

Choose a reason for hiding this comment

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

🟠 Code Vulnerability

Workflow depends on a GitHub actions pinned by tag (...read more)

When using a third party action, one needs to provide its GitHub path (owner/project) and can eventually pin it to a Git ref (a branch name, a Git tag, or a commit hash).

No pinned Git ref means the action uses the latest commit of the default branch each time it runs, eventually running newer versions of the code that were not audited by Datadog. Specifying a Git tag is better, but since they are not immutable, using a full length hash is recommended to make sure the action content is actually frozen to some reviewed state.

Be careful however, as even pinning an action by hash can be circumvented by attackers still. For instance, if an action relies on a Docker image which is itself not pinned to a digest, it becomes possible to alter its behaviour through the Docker image without actually changing its hash. You can learn more about this kind of attacks in Unpinnable Actions: How Malicious Code Can Sneak into Your GitHub Actions Workflows. Pinning actions by hash is still a good first line of defense against supply chain attacks.

Additionally, pinning by hash or tag means the action won’t benefit from newer version updates if any, including eventual security patches. Make sure to regularly check if newer versions for an action you use are available. For actions coming from a very trustworthy source, it can make sense to use a laxer pinning policy to benefit from updates as soon as possible.

View in Datadog  Leave us feedback  Documentation

- name: run unit tests and E2E tests (fake cluster)
run: |
make test
- uses: codecov/codecov-action@v2

Choose a reason for hiding this comment

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

🟠 Code Vulnerability

Workflow depends on a GitHub actions pinned by tag (...read more)

When using a third party action, one needs to provide its GitHub path (owner/project) and can eventually pin it to a Git ref (a branch name, a Git tag, or a commit hash).

No pinned Git ref means the action uses the latest commit of the default branch each time it runs, eventually running newer versions of the code that were not audited by Datadog. Specifying a Git tag is better, but since they are not immutable, using a full length hash is recommended to make sure the action content is actually frozen to some reviewed state.

Be careful however, as even pinning an action by hash can be circumvented by attackers still. For instance, if an action relies on a Docker image which is itself not pinned to a digest, it becomes possible to alter its behaviour through the Docker image without actually changing its hash. You can learn more about this kind of attacks in Unpinnable Actions: How Malicious Code Can Sneak into Your GitHub Actions Workflows. Pinning actions by hash is still a good first line of defense against supply chain attacks.

Additionally, pinning by hash or tag means the action won’t benefit from newer version updates if any, including eventual security patches. Make sure to regularly check if newer versions for an action you use are available. For actions coming from a very trustworthy source, it can make sense to use a laxer pinning policy to benefit from updates as soon as possible.

View in Datadog  Leave us feedback  Documentation

with:
apt-get: mercurial jq build-essential
- name: Check out code into the Go module directory
uses: actions/checkout@v1

Choose a reason for hiding this comment

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

🟠 Code Vulnerability

Workflow depends on a GitHub actions pinned by tag (...read more)

When using a third party action, one needs to provide its GitHub path (owner/project) and can eventually pin it to a Git ref (a branch name, a Git tag, or a commit hash).

No pinned Git ref means the action uses the latest commit of the default branch each time it runs, eventually running newer versions of the code that were not audited by Datadog. Specifying a Git tag is better, but since they are not immutable, using a full length hash is recommended to make sure the action content is actually frozen to some reviewed state.

Be careful however, as even pinning an action by hash can be circumvented by attackers still. For instance, if an action relies on a Docker image which is itself not pinned to a digest, it becomes possible to alter its behaviour through the Docker image without actually changing its hash. You can learn more about this kind of attacks in Unpinnable Actions: How Malicious Code Can Sneak into Your GitHub Actions Workflows. Pinning actions by hash is still a good first line of defense against supply chain attacks.

Additionally, pinning by hash or tag means the action won’t benefit from newer version updates if any, including eventual security patches. Make sure to regularly check if newer versions for an action you use are available. For actions coming from a very trustworthy source, it can make sense to use a laxer pinning policy to benefit from updates as soon as possible.

View in Datadog  Leave us feedback  Documentation

@levan-m levan-m force-pushed the clamoriniere/update-golang-auto branch from a84f748 to 001dd2c Compare October 22, 2024 17:48
@levan-m levan-m merged commit eb50a22 into main Oct 22, 2024
20 checks passed
@levan-m levan-m deleted the clamoriniere/update-golang-auto branch October 22, 2024 18:51
levan-m added a commit that referenced this pull request Oct 22, 2024
* automate golang version update

* Add tooling to update golang version in all the places that it is
defined.
* Use the go ersion present in go.work to update the version everywhere.
* Update the go.mod files to use the go workspace.
* Fix some issues is the makefile
* Add in the CI a job to verify that the golang version in properly sync
  everywhere.

* only use minor version for go version go.mod

* Test skopeo build in gitlab ci

* fix go.work

* Fix publish community PRs job (#1474)

* test skopeo install and rh bundle

* go work sync

* update publish_community_operators job

* remove test-skopeo job

* sync workspace

* go mod tidy

* e2e, go mod tidy

---------

Co-authored-by: Levan Machablishvili <levan.machablishvili@datadoghq.com>
Co-authored-by: Fanny Jiang <fanny.jiang@datadoghq.com>
Co-authored-by: levan-m <116471169+levan-m@users.noreply.github.com>
levan-m added a commit that referenced this pull request Oct 22, 2024
* automate golang version update

* Add tooling to update golang version in all the places that it is
defined.
* Use the go ersion present in go.work to update the version everywhere.
* Update the go.mod files to use the go workspace.
* Fix some issues is the makefile
* Add in the CI a job to verify that the golang version in properly sync
  everywhere.

* only use minor version for go version go.mod

* Test skopeo build in gitlab ci

* fix go.work

* Fix publish community PRs job (#1474)

* test skopeo install and rh bundle

* go work sync

* update publish_community_operators job

* remove test-skopeo job

* sync workspace

* go mod tidy

* e2e, go mod tidy

---------

Co-authored-by: Cedric Lamoriniere <cedric.lamoriniere@datadoghq.com>
Co-authored-by: Fanny Jiang <fanny.jiang@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants