-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix builtin arg for author; add two new args (#4016)
1. Add EARTHLY_GIT_AUTHOR_EMAIL and `EARTHLY_GIT_AUTHOR_NAME` built-in args. 2. Address #3822
- Loading branch information
Showing
10 changed files
with
141 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,19 +43,21 @@ RUN echo "The current target is $EARTHLY_TARGET" | |
|
||
### Git-related args | ||
|
||
| Name | Description | Example value | | ||
| --- | --- | --- | | ||
| `EARTHLY_GIT_AUTHOR` | The git author detected within the build context directory. If no git directory is detected, then the value is an empty string. | `John Doe <[email protected]>` | | ||
| `EARTHLY_GIT_CO_AUTHORS` | The git co-authors detected within the build context directory, separated by space. If no git directory is detected, then the value is an empty string. | `Jane Doe <[email protected] Jack Smith <[email protected]>` | | ||
| `EARTHLY_GIT_COMMIT_AUTHOR_TIMESTAMP` | The author timestamp, as unix seconds, of the git commit detected within the build context directory. If no git directory is detected, then the value is an empty string. | `1626881847` | | ||
| `EARTHLY_GIT_BRANCH` | The git branch of the git commit detected within the build context directory. If no git directory is detected, then the value is an empty string. | `main` | | ||
| `EARTHLY_GIT_COMMIT_TIMESTAMP` | The committer timestamp, as unix seconds, of the git commit detected within the build context directory. If no git directory is detected, then the value is an empty string. | `1626881847` | | ||
| `EARTHLY_GIT_HASH` | The git hash detected within the build context directory. If no git directory is detected, then the value is an empty string. Take care when using this arg, as the frequently changing git hash may be cause for not using the cache. | `41cb5666ade67b29e42bef121144456d3977a67a` | | ||
| `EARTHLY_GIT_ORIGIN_URL` | The git URL detected within the build context directory. If no git directory is detected, then the value is an empty string. Please note that this may be inconsistent, depending on whether an HTTPS or SSH URL was used. | `[email protected]:bar/buz.git` or `https://github.com/bar/buz.git` | | ||
| `EARTHLY_GIT_PROJECT_NAME` | The git project name from within the git URL detected within the build context directory. If no git directory is detected, then the value is an empty string. | `bar/buz` | | ||
| `EARTHLY_GIT_REFS` | The git references of the git commit detected within the build context directory, separated by space. If no git directory is detected, then the value is an empty string. | `issue-2735-git-ref main` | | ||
| `EARTHLY_GIT_SHORT_HASH` | The first 8 characters of the git hash detected within the build context directory. If no git directory is detected, then the value is an empty string. Take care when using this arg, as the frequently changing git hash may be cause for not using the cache. | `41cb5666` | | ||
| `EARTHLY_SOURCE_DATE_EPOCH` | The timestamp, as unix seconds, of the git commit detected within the build context directory. If no git directory is detected, then the value is `0` (the unix epoch) | `1626881847`, `0` | | ||
| Name | Description | Example value | Feature Flag | | ||
| --- | --- | --- |----------------------------------------| | ||
| `EARTHLY_GIT_AUTHOR` | The git author detected within the build context directory. If no git directory is detected, then the value is an empty string. This is currently the author's email address but the feature flag adds the name as well | `[email protected]` (or `John Doe <[email protected]>` with flag turned on) | `--earthly-git-author-individual-args` | | ||
| `EARTHLY_GIT_AUTHOR_EMAIL` | The git author email detected within the build context directory. If no git directory is detected, then the value is an empty string. | `[email protected]` | `--earthly-git-author-individual-args` | | ||
| `EARTHLY_GIT_AUTHOR_NAME` | The git author name detected within the build context directory. If no git directory is detected, then the value is an empty string. | `John Doe` | `--earthly-git-author-individual-args` | | ||
| `EARTHLY_GIT_CO_AUTHORS` | The git co-authors detected within the build context directory, separated by space. If no git directory is detected, then the value is an empty string. | `Jane Doe <[email protected] Jack Smith <[email protected]>` | | | ||
| `EARTHLY_GIT_COMMIT_AUTHOR_TIMESTAMP` | The author timestamp, as unix seconds, of the git commit detected within the build context directory. If no git directory is detected, then the value is an empty string. | `1626881847` | | | ||
| `EARTHLY_GIT_BRANCH` | The git branch of the git commit detected within the build context directory. If no git directory is detected, then the value is an empty string. | `main` | | | ||
| `EARTHLY_GIT_COMMIT_TIMESTAMP` | The committer timestamp, as unix seconds, of the git commit detected within the build context directory. If no git directory is detected, then the value is an empty string. | `1626881847` | | | ||
| `EARTHLY_GIT_HASH` | The git hash detected within the build context directory. If no git directory is detected, then the value is an empty string. Take care when using this arg, as the frequently changing git hash may be cause for not using the cache. | `41cb5666ade67b29e42bef121144456d3977a67a` | | | ||
| `EARTHLY_GIT_ORIGIN_URL` | The git URL detected within the build context directory. If no git directory is detected, then the value is an empty string. Please note that this may be inconsistent, depending on whether an HTTPS or SSH URL was used. | `[email protected]:bar/buz.git` or `https://github.com/bar/buz.git` | | | ||
| `EARTHLY_GIT_PROJECT_NAME` | The git project name from within the git URL detected within the build context directory. If no git directory is detected, then the value is an empty string. | `bar/buz` | | | ||
| `EARTHLY_GIT_REFS` | The git references of the git commit detected within the build context directory, separated by space. If no git directory is detected, then the value is an empty string. | `issue-2735-git-ref main` | | | ||
| `EARTHLY_GIT_SHORT_HASH` | The first 8 characters of the git hash detected within the build context directory. If no git directory is detected, then the value is an empty string. Take care when using this arg, as the frequently changing git hash may be cause for not using the cache. | `41cb5666` | | | ||
| `EARTHLY_SOURCE_DATE_EPOCH` | The timestamp, as unix seconds, of the git commit detected within the build context directory. If no git directory is detected, then the value is `0` (the unix epoch) | `1626881847`, `0` | | | ||
|
||
### Platform-related args | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,12 @@ test -n \"\$(git config --global user.email)\" | |
# clone the repo and add a test Earthfile to it | ||
git clone [email protected]:testuser/repo.git | ||
mv Earthfile repo/ | ||
git -C repo add Earthfile | ||
mkdir -p repo/flag_on repo/flag_off | ||
cp Earthfile repo/flag_on | ||
mv Earthfile repo/flag_off | ||
sed -i '1s/VERSION --git-author-email-name-args \(.*\)/VERSION \1/' ./repo/flag_off/Earthfile | ||
git -C repo add flag_on flag_off | ||
git -C repo commit -m \"test | ||
Co-authored-by: Testy McTest <[email protected]> | ||
|
@@ -58,40 +62,80 @@ export expected_refs=\"\$(git -C repo for-each-ref --points-at HEAD --format '%( | |
test -n \"\$expected_refs\" | ||
# finally perform earthly tests | ||
# flag --git-author-email-name-args on | ||
earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch \ | ||
--build-arg expected_refs \ | ||
./repo/flag_on+test-git-metadata | ||
EARTHLY_GIT_BRANCH_OVERRIDE=branch-override earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch=branch-override \ | ||
--build-arg expected_refs \ | ||
./repo/flag_on+test-git-metadata | ||
# flag --git-author-email-name-args off | ||
earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch \ | ||
--build-arg expected_refs \ | ||
./repo+test-git-metadata | ||
--build-arg flag_on=false \ | ||
./repo/flag_off+test-git-metadata | ||
EARTHLY_GIT_BRANCH_OVERRIDE=branch-override earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch=branch-override \ | ||
--build-arg expected_refs \ | ||
./repo+test-git-metadata | ||
--build-arg flag_on=false \ | ||
./repo/flag_off+test-git-metadata | ||
rm -rf repo | ||
export expected_refs=\"main\" | ||
# flag on | ||
earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch \ | ||
--build-arg expected_refs \ | ||
git.example.com/testuser/repo/flag_on:main+test-git-metadata | ||
EARTHLY_GIT_BRANCH_OVERRIDE=branch-override earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch=branch-override \ | ||
--build-arg expected_refs \ | ||
git.example.com/testuser/repo/flag_on:main+test-git-metadata | ||
# flag off | ||
earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch \ | ||
--build-arg expected_refs \ | ||
git.example.com/testuser/repo:main+test-git-metadata | ||
--build-arg flag_on=false \ | ||
git.example.com/testuser/repo/flag_off:main+test-git-metadata | ||
EARTHLY_GIT_BRANCH_OVERRIDE=branch-override earthly --config \$earthly_config --verbose -D \ | ||
--build-arg expected_sha \ | ||
--build-arg expected_committer_timestamp \ | ||
--build-arg expected_author_timestamp \ | ||
--build-arg expected_branch=branch-override \ | ||
--build-arg expected_refs \ | ||
git.example.com/testuser/repo:main+test-git-metadata | ||
--build-arg flag_on=false \ | ||
git.example.com/testuser/repo/flag_off:main+test-git-metadata | ||
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script | ||
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --exec_cmd=/tmp/test-earthly-script | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
VERSION 0.8 | ||
VERSION --git-author-email-name-args 0.8 | ||
|
||
# Note: this is tests both locally and remotely | ||
# the population of git metadata occurs in two **different** functions respectively: | ||
|
@@ -12,9 +12,21 @@ test-git-metadata: | |
ARG --required expected_author_timestamp | ||
ARG --required expected_branch | ||
ARG --required expected_refs | ||
ARG flag_on=true | ||
LET expected_author="[email protected]" | ||
LET expected_author_email="" | ||
LET expected_author_name="" | ||
IF [ "$flag_on" = "true" ] | ||
SET expected_author="test name <[email protected]>" | ||
SET expected_author_email="[email protected]" | ||
SET expected_author_name="test name" | ||
END | ||
|
||
ARG EARTHLY_GIT_SHORT_HASH | ||
ARG EARTHLY_GIT_HASH | ||
ARG EARTHLY_GIT_AUTHOR | ||
ARG EARTHLY_GIT_AUTHOR_EMAIL | ||
ARG EARTHLY_GIT_AUTHOR_NAME | ||
ARG EARTHLY_GIT_CO_AUTHORS | ||
ARG EARTHLY_GIT_COMMIT_TIMESTAMP | ||
ARG EARTHLY_GIT_COMMIT_AUTHOR_TIMESTAMP | ||
|
@@ -27,5 +39,7 @@ test-git-metadata: | |
RUN test "$EARTHLY_GIT_REFS" = "$expected_refs" | ||
RUN test -n "$EARTHLY_GIT_SHORT_HASH" | ||
RUN echo "$EARTHLY_GIT_HASH" | grep "$EARTHLY_GIT_SHORT_HASH" | ||
RUN test "$EARTHLY_GIT_AUTHOR" = "[email protected]" | ||
RUN test "$EARTHLY_GIT_AUTHOR" = "$expected_author" | ||
RUN test "$EARTHLY_GIT_AUTHOR_EMAIL" = "$expected_author_email" | ||
RUN test "$EARTHLY_GIT_AUTHOR_NAME" = "$expected_author_name" | ||
RUN test "$EARTHLY_GIT_CO_AUTHORS" = "[email protected] [email protected]" |
Oops, something went wrong.