-
Notifications
You must be signed in to change notification settings - Fork 1
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
Windows compat tasks #20
Changes from all commits
2c94dca
df14c0e
13182bb
8fb320e
21257d6
0e0d123
880d8db
9e5eb89
b0f98e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Prevent CRLF correction from changing digest of | ||
# text files that are committed as stand-ins for binaries | ||
# in text fixtures: | ||
/tool/testdata/store/** -text |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,9 @@ TASK = $(TOOL_DIR)/task | |
## Bootstrapping targets ################################# | ||
|
||
$(BINNY): | ||
@mkdir -p $(TOOL_DIR) | ||
@# we don't have a release of binny yet, so build off of the current branch | ||
@#curl -sSfL https://raw.githubusercontent.com/$(OWNER)/$(PROJECT)/main/install.sh | sh -s -- -b $(TOOL_DIR) | ||
@-mkdir $(TOOL_DIR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
# we don't have a release of binny yet, so build off of the current branch | ||
# curl -sSfL https://raw.githubusercontent.com/$(OWNER)/$(PROJECT)/main/install.sh | sh -s -- -b $(TOOL_DIR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're going to have to solve this for every other repo, just not this one since it has binny go code... |
||
go build -o $(TOOL_DIR)/$(PROJECT) ./cmd/$(PROJECT) | ||
|
||
.PHONY: task | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ vars: | |
SNAPSHOT_DIR: snapshot | ||
CHANGELOG: CHANGELOG.md | ||
NEXT_VERSION: VERSION | ||
MAKEDIR_P: 'python -c "import sys; import os; os.makedirs(sys.argv[1], exist_ok=True)"' | ||
|
||
tasks: | ||
|
||
|
@@ -122,15 +123,15 @@ tasks: | |
desc: Run all unit tests | ||
vars: | ||
TEST_PKGS: | ||
sh: "go list ./... | grep -v {{ .OWNER }}/{{ .PROJECT }}/test | tr '\n' ' '" | ||
sh: "python ./scripts/list_units.py anchore binny" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we have binny, can we just have it download There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My concern is that the utilities won't behave the same even if we make them available. For example In other words, if we keep using a command shell as our scripting environment, we have to worry about the compatibility of every executable the shell invokes. If we use standard library Python, we only have to worry about the cross-platform behavior of Python itself. |
||
|
||
# unit test coverage threshold (in % coverage) | ||
COVERAGE_THRESHOLD: 45 | ||
COVERAGE_THRESHOLD: '{{if eq OS "windows"}} 43 {{else}} 45 {{end}}' | ||
cmds: | ||
- cmd: "mkdir -p {{ .TMP_DIR }}" | ||
- cmd: "{{ .MAKEDIR_P }} {{ .TMP_DIR }}" | ||
silent: true | ||
- "go test -coverprofile {{ .TMP_DIR }}/unit-coverage-details.txt {{ .TEST_PKGS }}" | ||
- cmd: ".github/scripts/coverage.py {{ .COVERAGE_THRESHOLD }} {{ .TMP_DIR }}/unit-coverage-details.txt" | ||
- cmd: '{{if eq OS "windows"}}python {{end}}.github/scripts/coverage.py {{ .COVERAGE_THRESHOLD }} {{ .TMP_DIR }}/unit-coverage-details.txt' | ||
silent: true | ||
|
||
## Build-related targets ################################# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import subprocess | ||
import sys | ||
|
||
def go_list_exclude_pattern(owner, project): | ||
exclude_pattern = f"{owner}/{project}/test" | ||
|
||
result = subprocess.run(["go", "list", "./..."], stdout=subprocess.PIPE, text=True, check=True) | ||
|
||
filtered_lines = [line for line in result.stdout.splitlines() if exclude_pattern not in line] | ||
|
||
joined_output = ' '.join(filtered_lines) | ||
|
||
return joined_output | ||
|
||
owner = sys.argv[1] | ||
project = sys.argv[2] | ||
output = go_list_exclude_pattern(owner, project) | ||
print(output) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ package goinstall | |
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
@@ -108,6 +110,7 @@ func TestInstaller_InstallTo(t *testing.T) { | |
i.goInstallRunner = tt.fields.goInstallRunner | ||
|
||
got, err := i.InstallTo(tt.args.version, tt.args.destDir) | ||
got = strings.ReplaceAll(got, string(os.PathSeparator), "/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test fails for me because there is no |
||
if !tt.wantErr(t, err, fmt.Sprintf("InstallTo(%v, %v)", tt.args.version, tt.args.destDir)) { | ||
return | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this doesn't use the caching that we'd get from using our own
actions/bootstrap
here, but that has some entries that requireshell: bash
which presumably won't work on Windows, and I don't know why it needs those yet.