Skip to content

Uses make in windows #325

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

Merged
merged 3 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,66 @@ jobs:
name: "Run unit tests (${{ matrix.os }})"
runs-on: ${{ matrix.os }}
timeout-minutes: 90 # instead of 360 by default

strategy:
fail-fast: false # don't fail fast as sometimes failures are operating system specific
matrix:
os: [ ubuntu-latest, macos-latest ]
os: [ubuntu-latest, macos-latest]
include:
- os: windows-latest
# Until GHA allows a cygwin runner, we have to override the default bash
shell: C:\tools\cygwin\bin\bash.exe --login -o errexit -o nounset -o pipefail -o igncr -i {0}

defaults:
run:
shell: ${{ matrix.shell || 'bash' }}
Copy link
Member

Choose a reason for hiding this comment

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

I didn't know that we can use|| stuff in the GHA expression 😄


steps:
# This sets up the environment we need for Windows, but isn't in the default image:
# * install make and cygwin's bash which resolves paths correctly for .bingo/Variables.mk
# * configure git so line-feeds don't trip lint https://github.com/actions/checkout/issues/135
#
# Note: We don't need to install anything here (ex wixtoolset):
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md
- name: "Pre-configure (Windows)"
if: runner.os == 'Windows'
run: |
choco install -y --no-progress --source cygwin make bash
git config --global core.autocrlf input
git config --global core.eol lf
shell: bash

- name: "Checkout"
uses: actions/checkout@v2

# The current working directory is lost when we run cygwin-bash in Windows.
# This ensures each new `run:` has the correct directory, and that it is correctly translated.
- name: "Ensure working directory (Windows)"
if: runner.os == 'Windows'
run: printf 'cd %s' "$(cygpath '${{ github.workspace }}')" >> ~/.bashrc

- name: "Install Go"
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: "Cache dependencies"
- name: "Cache golang"
uses: actions/cache@v2
with:
# This combines unrelated caches because actions/cache@v2 doesn't support multiple
# instances, rather a combined path. https://github.com/actions/cache/issues/16
path: | # ~/.func-e/versions is cached so that we only re-download once: for TestFuncEInstall
~/.func-e/versions
path: | # TODO: go build cache if we care, noting it is OS-specific
~/go/pkg/mod
~/go/bin/*-v*
# '.bingo/*.sum' files generate inconsistently when building `~/go/bin/*-v*`. We key '.bingo/*.mod' instead.
key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('internal/version/last_known_envoy.txt', 'go.sum', '.bingo/*.mod') }}
key: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-${{ hashFiles('go.sum', '.bingo/*.mod') }}
restore-keys: test-${{ runner.os }}-${{ env.GO_VERSION }}-go-

- name: "Cache Envoy binaries"
uses: actions/cache@v2
with: # ~/.func-e/versions is cached so that we only re-download once: for TestFuncEInstall
path: ~/.func-e/versions
key: test-${{ runner.os }}-envoy-${{ hashFiles('internal/version/last_known_envoy.txt') }}
restore-keys: test-${{ runner.os }}-envoy-

- name: "Verify clean check-in"
run: make check

Expand All @@ -73,46 +107,12 @@ jobs:
- name: "Run e2e tests using the `func-e` binary"
run: make e2e

- name: "Generate coverage report" # only once (not per OS)
- name: "Generate coverage report" # only once (not per OS)
if: runner.os == 'Linux'
run: make coverage

- name: "Upload coverage report" # only on master push and only once (not per OS)
- name: "Upload coverage report" # only on master push and only once (not per OS)
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && runner.os == 'Linux'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)

test-windows:
name: "Run unit tests (windows-latest)"
runs-on: windows-latest
timeout-minutes: 90 # instead of 360 by default
steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Install Go"
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: "Cache dependencies"
uses: actions/cache@v2
with:
# This combines unrelated caches because actions/cache@v2 doesn't support multiple
# instances, rather a combined path. https://github.com/actions/cache/issues/16
path: | # ~\.func-e\versions is cached so that we only re-download once: for TestFuncEInstall
~\.func-e\versions
~\go\pkg\mod
key: test-windows-latest-${{ env.GO_VERSION }}-go-${{ hashFiles('internal/version/last_known_envoy.txt', 'go.sum') }}
restore-keys: test-windows-latest-${{ env.GO_VERSION }}-go-

- name: "Run unit tests"
run: go test . ./internal/...

- name: "Build the `func-e` binary"
run: go build --ldflags '-s -w' .

- name: "Run e2e tests using the `func-e` binary"
run: go test -parallel 1 -v -failfast ./e2e

3 changes: 2 additions & 1 deletion .licenserignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ site/*.json
e2e/*.yaml

netlify.toml
site/
site/
packaging/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test:
.PHONY: e2e
e2e: $(BIN)
@echo "--- e2e ---"
@E2E_FUNC_E_PATH=$(PWD)/$(BIN) go test -parallel 1 -v -failfast ./e2e
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing this allowed one less translation problem in cygwin. It is now allowed to be and defaults to relative to the project root.

@E2E_FUNC_E_PATH=$(BIN) go test -parallel 1 -v -failfast ./e2e

##@ Code quality and integrity

Expand Down
19 changes: 16 additions & 3 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ func mockEnvoyVersionsServer() (*httptest.Server, error) {
func readFuncEBin() error {
path := os.Getenv(funcEPathEnvKey)
if path != "" {
if !filepath.IsAbs(path) {
return fmt.Errorf("%s is not an absolute path. Correct environment variable %s", path, funcEPathEnvKey)
p, err := abs(path)
if err != nil {
return err
}
path = filepath.Clean(path)
path = filepath.Clean(p)
stat, err := os.Stat(path)
if err != nil && os.IsNotExist(err) {
return fmt.Errorf("%s doesn't exist. Correct environment variable %s", path, funcEPathEnvKey)
Expand Down Expand Up @@ -146,6 +147,18 @@ func readFuncEBin() error {
return nil
}

// abs is like filepath.Abs except the correct relative dir is '..'
func abs(path string) (string, error) {
if !filepath.IsAbs(path) {
wd, err := os.Getwd()
if err != nil {
return "", fmt.Errorf("could not get current directory")
}
path = filepath.Join(wd, "..", path)
}
return path, nil
}

type funcE struct {
cmd *exec.Cmd
runDir string
Expand Down
2 changes: 1 addition & 1 deletion internal/moreos/proc_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func ensureProcessDone(p *os.Process) error {
}
return os.NewSyscallError("OpenProcess", e)
}
defer syscall.CloseHandle(h)
defer syscall.CloseHandle(h) //nolint:errcheck

// Try to wait for the process to close naturally first, using logic from exec_windows/findProcess()
// Difference here, is we are waiting 100ms not infinite. If there's a timeout, we kill the proc.
Expand Down