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 overrides on Windows #51

Merged
merged 1 commit into from
Feb 23, 2022
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
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches: [ main ]

jobs:
test:
name: Test
check:
name: Project checks
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
Expand All @@ -23,6 +23,21 @@ jobs:
with:
working-directory: src/github.com/containerd/protobuild

test:
name: Test
strategy:
matrix:
os: [ ubuntu-20.04, windows-2022 ]
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: src/github.com/containerd/protobuild
fetch-depth: 25

- name: Setup environment
shell: bash
run: |
Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ func parseVersion(s string) (int, error) {
return v, nil
}

func importPath(base, target string) (string, error) {
rel, err := filepath.Rel(base, target)
if err != nil {
return "", err
}
return filepath.ToSlash(rel), nil
}

func main() {
flag.Parse()

Expand Down Expand Up @@ -199,7 +207,7 @@ func main() {
Version: version,
}

importDirPath, err := filepath.Rel(outputDir, pkg.Dir)
importDirPath, err := importPath(outputDir, pkg.Dir)
if err != nil {
log.Fatalln(err)
}
Expand Down
31 changes: 31 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright The containerd Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import "testing"

func TestImportPath(t *testing.T) {
path, err := importPath("/home/alice/go/src", "/home/alice/go/src/github.com/containerd/foobar")
if err != nil {
t.Fatalf("got %s", err)
}

expected := "github.com/containerd/foobar"
if path != expected {
t.Fatalf("got %s, expected %s", path, expected)
}
}