-
Notifications
You must be signed in to change notification settings - Fork 32
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
Makefile: tests: set GIT_DIR #145
Makefile: tests: set GIT_DIR #145
Conversation
f6f9e1b
to
9f645f2
Compare
9f645f2
to
6231ce6
Compare
And the checks are not passing for templating using the git hashes |
6231ce6
to
4c48621
Compare
Oh, I missed that comment, I will check that. EDIT; I was blindly trusting the CI 🤦. The failing tests are the tests I made to justify the change 😭 that is ironic. |
0350618
to
fa67aab
Compare
@florentsfl, I finally making it works! |
Now it has some (small) conflicts since we merged the shellcheck PR; I can merge that one after you solve them 😃 |
The git-log commands run to replace the git templates (short or long hash of the last commmit) fail during the tests, as the test cd to another directory, and thus left the git repository. The error fails silently and it does not break the execution of cqfd because the local declaration and the assignment are both performed simultaneously, masking the returned value. See shellcheck errors below: In cqfd line 301: local git_short=$(git rev-parse --short HEAD 2>/dev/null) ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values. In cqfd line 302: local git_long=$(git rev-parse HEAD 2>/dev/null) ^------^ SC2155 (warning): Declare and assign separately to avoid masking return values. In cqfd line 303: local date_rfc3339=$(date +"%Y-%m-%d") ^----------^ SC2155 (warning): Declare and assign separately to avoid masking return values. In cqfd line 304: local date_unix=$(date +%s) ^-------^ SC2155 (warning): Declare and assign separately to avoid masking return values. This sets the GIT_DIR to ensure the git-log commands run by cqfd release succeeds during the tests. So one can implement the tests using the git-log templates. See git(1): OPTIONS --git-dir=<path> Set the path to the repository (".git" directory). This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory. Specifying the location of the ".git" directory using this option (or GIT_DIR environment variable) turns off the repository discovery that tries to find a directory with ".git" subdirectory (which is how the repository and the top-level of the working tree are discovered), and tells Git that you are at the top level of the working tree. If you are not at the top-level directory of the working tree, you should tell Git where the top-level of the working tree is, with the --work-tree=<path> option (or GIT_WORK_TREE environment variable) If you just want to run git as if it was started in <path> then use git -C <path>. ENVIRONMENT VARIABLES GIT_DIR If the GIT_DIR environment variable is set then it specifies a path to use instead of the default .git for the base of the repository. The --git-dir command-line option also sets this value. Fixes: diff --git a/cqfd b/cqfd --- a/cqfd +++ b/cqfd @@ -298,10 +298,10 @@ make_archive() { done # template the generated archive's filename - local git_short=$(git rev-parse --short HEAD 2>/dev/null) - local git_long=$(git rev-parse HEAD 2>/dev/null) - local date_rfc3339=$(date +"%Y-%m-%d") - local date_unix=$(date +%s) + git_short=$(git rev-parse --short HEAD 2>/dev/null) + git_long=$(git rev-parse HEAD 2>/dev/null) + date_rfc3339=$(date +"%Y-%m-%d") + date_unix=$(date +%s) # default name for the archive if not set if [ -z "$release_archive" ]; then [22:58:34|info] ----------------------------------------------------- [22:58:34|info] started from ./06-cqfd_release in /tmp/tmp.iTL5Rn2FsD [22:58:34|notice] preparing "cqfd release fails without files parameter" cqfd: fatal: No files to archive, check files in .cqfdrc [22:58:35|info] result: cqfd release fails without files parameter: PASS [22:58:35|notice] preparing "cqfd release now with a files parameter" [22:58:37|info] result: cqfd release now with a files parameter: FAIL [22:58:37|notice] preparing "default orgname-project.tar.xz archive is generated" [22:58:37|info] result: default orgname-project.tar.xz archive is generated: FAIL [22:58:37|notice] preparing "archived files NOT at root of tar archive" tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now [22:58:37|info] result: archived files NOT at root of tar archive: FAIL [22:58:37|notice] preparing "archived files NOT at root of tar archive if tar_transform=no" [22:58:38|error] error triggered by ./06-cqfd_release tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now [22:58:38|info] result: archived files NOT at root of tar archive if tar_transform=no: FAIL [22:58:38|notice] preparing "archived files at root of tar archive if tar_transform=yes" [22:58:40|error] error triggered by ./06-cqfd_release tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now [22:58:40|info] result: archived files at root of tar archive if tar_transform=yes: FAIL [22:58:40|notice] preparing "symlink files are copied in the tar archive" [22:58:43|error] error triggered by ./06-cqfd_release tar: cqfd-test.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now diff: /tmp/tmp.scEI0uhoUm/a/cqfd_a.txt: No such file or directory diff: /tmp/tmp.scEI0uhoUm/link.txt: No such file or directory [22:58:43|info] result: symlink files are copied in the tar archive: FAIL [22:58:45|notice] preparing "build.archive can template filenames" [22:58:46|error] error triggered by ./06-cqfd_release [22:58:46|info] result: build.archive can template filenames: FAIL [22:58:46|notice] preparing "build.archive can make a .tar.gz archive" [22:58:48|error] error triggered by ./06-cqfd_release [22:58:48|info] result: build.archive can make a .tar.gz archive: FAIL [22:58:48|notice] preparing "build.archive can make a .zip archive" [22:58:49|error] error triggered by ./06-cqfd_release [22:58:49|info] result: build.archive can make a .zip archive: FAIL [22:58:49|notice] preparing "release for flavor foo creates cqfd-foo.tar.xz" making foo [22:58:51|error] error triggered by ./06-cqfd_release [22:58:51|info] result: release for flavor foo creates cqfd-foo.tar.xz: FAIL [22:58:51|notice] preparing "release for flavor bar creates cqfd-bar.tar.xz" making bar [22:58:53|error] error triggered by ./06-cqfd_release [22:58:53|info] result: release for flavor bar creates cqfd-bar.tar.xz: FAIL [22:58:53|notice] preparing "cqfd fails on missing file in build.files" cqfd: fatal: Unable to release: unable to find ThisFileDoesNotExist.txt [22:58:54|info] result: cqfd fails on missing file in build.files: PASS [22:58:54|notice] preparing "cqfd resolves globs in build.files" [22:58:56|info] result: cqfd resolves globs in build.files: FAIL [22:58:56|notice] preparing "resolved globs are properly archived" tar: cqfd-foobar.tar.xz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now [22:58:56|error] error triggered by ./06-cqfd_release [22:58:56|info] result: resolved globs are properly archived: FAIL [22:58:56|error] returning error as ./06-cqfd_release produced errors (...) |PASS|cqfd release fails without files parameter **|FAIL|cqfd release now with a files parameter **|FAIL|default orgname-project.tar.xz archive is generated **|FAIL|archived files NOT at root of tar archive **|FAIL|archived files NOT at root of tar archive if tar_transform=no **|FAIL|archived files at root of tar archive if tar_transform=yes **|FAIL|symlink files are copied in the tar archive **|FAIL|build.archive can template filenames **|FAIL|build.archive can make a .tar.gz archive **|FAIL|build.archive can make a .zip archive **|FAIL|release for flavor foo creates cqfd-foo.tar.xz **|FAIL|release for flavor bar creates cqfd-bar.tar.xz |PASS|cqfd fails on missing file in build.files **|FAIL|cqfd resolves globs in build.files **|FAIL|resolved globs are properly archived
This includes the testing for the command cqfd release, in the situation of it fails before releasing the file.
This adds the tests for all the archive templates, including literal %.
This sets the default value "unset" if cannot get the git revision hash.
The "$HOME/.gitconfig" is a directory in the runnger causing some git commands may fail: git log -1 || true + git log -1 true (...) warning: unable to access '/home/runner/.gitconfig': Is a directory warning: unable to access '/home/runner/.gitconfig': Is a directory warning: unable to access '/home/runner/.gitconfig': Is a directory fatal: unknown error occurred while reading the configuration files According to git(1): ENVIRONMENT VARIABLES (...) GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM Take the configuration from the given files instead from global or system-level configuration files. If GIT_CONFIG_SYSTEM is set, the system config file defined at build time (usually /etc/gitconfig) will not be read. Likewise, if GIT_CONFIG_GLOBAL is set, neither $HOME/.gitconfig nor $XDG_CONFIG_HOME/git/config will be read. Can be set to /dev/null to skip reading configuration files of the respective level. This skips reading configuration files by setting GIT_CONFIG_GLOBAL to /dev/null: GIT_CONFIG_GLOBAL=/dev/null export GIT_CONFIG_GLOBAL git log -1 || true + GIT_CONFIG_GLOBAL=/dev/null + export GIT_CONFIG_GLOBAL + git log -1 commit 2cd9007a06aeca5e76bb64b1025010e87ffdf151 (HEAD) Author: Gaël PORTAY <gael.portay@rtone.fr> Date: Mon Feb 17 22:26:18 2025 +0100 .github: fix git usage
66aed54
to
2fc5ecf
Compare
The git-log commands run to replace the git templates (short or long hash of the last commmit) fail during the tests, as the test cd to another directory, and thus left the git repository.
The error fails silently and it does not break the execution of cqfd because the local declaration and the assignment are both performed simultaneously, masking the returned value. See shellcheck errors below:
This sets the GIT_DIR to ensure the git-log commands run by cqfd release succeeds during the tests. So one can implement the tests using the git-log templates.
See git(1):
Fixes: