Skip to content

Commit

Permalink
Run tests on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
  • Loading branch information
kzys committed Feb 21, 2022
1 parent 7e5ee24 commit 92b6d20
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
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
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func parseVersion(s string) (int, error) {
return v, nil
}

func importPath(base, target string) (string, error) {
return filepath.Rel(base, target)
}

func main() {
flag.Parse()

Expand Down Expand Up @@ -199,7 +203,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)
}
}

0 comments on commit 92b6d20

Please sign in to comment.