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

fix for issue #3820 failed to make validate-git in local env #4094

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -31,6 +31,7 @@ bin/*

# Cover profiles
*.out
coverage.txt
Copy link
Member

Choose a reason for hiding this comment

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

why are you ignoring this?

Copy link
Author

Choose a reason for hiding this comment

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

sorry for the delay in answer:

the coverage.txt file is product of the make test-coverage action.
it is generated as a result of current file status in the developer work env and not the official file version stored in the git repo. there for it may provide false status of the state of coverage then the acutal code base has.
if it is needed as a persistant state indector, we should ensure it is ignored as default by developer commits and fource commit it's state as a CI pipeline stage.
in both cases it should be in the .gitignore list

example:
To check in a file into a Git repository and ensure that only the Continuous Integration (CI) system can update it, you can follow these general steps:

  1. Create the File:

    • Create the file that you want to add to the repository.
  2. Add the File to Git:

    • Use the following commands to add the file to the Git repository:

      git add your_file_name
      git commit -m "Add your_file_name to the repository"
  3. Add a .gitignore Entry:

    • To make sure the file is not accidentally modified or committed by developers, add an entry for the file in the .gitignore file. If the file is sensitive, consider not including it in the repository at all. The .gitignore file is used to specify intentionally untracked files that Git should ignore.

      Create or edit the .gitignore file and add the file name to it:

      your_file_name
      
  4. Protect the Branch:

    • Restrict write access to the branch where this file resides. You can use branch protection settings on platforms like GitHub, GitLab, or Bitbucket. For example, on GitHub:
      • Go to your repository on GitHub.
      • Click on the "Settings" tab.
      • Navigate to "Branches" or a similar section.
      • Enable branch protection for the branch containing your file.
      • Configure the branch protection rules, such as requiring pull request reviews, status checks, or other criteria.
  5. CI Configuration:

    • Set up your CI system to update the file. This usually involves updating the file during the build or deployment process triggered by CI.
    • Store any sensitive information needed for CI in secure environment variables or secret management systems provided by your CI platform.
  6. Encryption (Optional):

    • If the file contains sensitive information and needs to be stored in the repository, consider encrypting the file before committing it. The CI system can then decrypt it during the build process.

Remember to adapt these steps based on your specific CI system, version control platform, and project requirements. Always be cautious when handling sensitive information and follow best practices for security.

Copy link
Member

Choose a reason for hiding this comment

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

I know what the file is and I know how it's generated - I'm one of the maintainers of this project.
Why are you pasting all these snippet of some kinda README into this comment?

Copy link
Author

Choose a reason for hiding this comment

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

Guess I was writing too many md files lately that I write this in my mails
and comment to PRs as well. LOL

Sorry if my replay was too detailed / assumed you are not aware of this
file. Figured not just reviewers might read the conversation wanted the
contexts will be clear.

In the example I Just pasted the flow to "commit and ignore a file" so I would have it in the context of the change.


# Editor/IDE specific files.
*.sublime-project
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -6,6 +6,7 @@ ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# Used to populate version variable in main package.
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
REVISION ?= $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)
COMMIT_RANGE ?= $(shell git reflog show --no-abbrev --format='%h..HEAD')

# default compose command
COMPOSE ?= docker compose
Expand Down Expand Up @@ -159,7 +160,7 @@ validate: ## run all validators
docker buildx bake $@

validate-git: ## validate git
docker buildx bake $@
COMMIT_RANGE=$(COMMIT_RANGE) docker buildx bake $@

validate-vendor: ## validate vendor
docker buildx bake $@
Expand Down
2 changes: 1 addition & 1 deletion docker-bake.hcl
Expand Up @@ -12,7 +12,7 @@ target "lint" {
}

variable "COMMIT_RANGE" {
default = ""
default = "HEAD..HEAD"
}
target "validate-git" {
dockerfile = "./dockerfiles/git.Dockerfile"
Expand Down