Skip to content

Commit cefb82f

Browse files
authored
Run ci workflow on v2/. (#260)
* Enable aetest tests * Fix v2/aefix to work with appengine/v2 * Update Contributing docs
1 parent d0e56bd commit cefb82f

File tree

6 files changed

+133
-18
lines changed

6 files changed

+133
-18
lines changed

.github/workflows/ci-v2.yaml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: ci-v2
2+
3+
on:
4+
push:
5+
branches: [ master, qa ]
6+
pull_request:
7+
branches: [ master, qa ]
8+
9+
jobs:
10+
test-gomod-v2:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
go-version: [ '1.11.x', '1.12.x', '1.13.x', '1.14.x', '1.15.x']
15+
env:
16+
working-directory: ./v2
17+
18+
steps:
19+
- name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: ${{ matrix.go-version }}
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
- name: Cache go modules
26+
uses: actions/cache@v2
27+
with:
28+
path: |
29+
~/.cache/go-build
30+
~/go/pkg/mod
31+
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
32+
restore-keys: |
33+
${{ runner.os }}-${{ matrix.go-version }}-go-
34+
- name: Set up Cloud SDK
35+
uses: google-github-actions/setup-gcloud@master
36+
- name: Install
37+
working-directory: ${{env.working-directory}}
38+
env:
39+
GO111MODULE: on
40+
run: |
41+
go get .
42+
gcloud components install app-engine-python app-engine-go cloud-datastore-emulator --quiet
43+
- name: Test gomod v2
44+
env:
45+
GO111MODULE: on
46+
working-directory: ${{env.working-directory}}
47+
run: |
48+
export APPENGINE_DEV_APPSERVER=$(which dev_appserver.py)
49+
go test -v -cover -race google.golang.org/appengine/v2/...
50+
# TestAPICallAllocations doesn't run under race detector.
51+
go test -v -cover google.golang.org/appengine/v2/internal/... -run TestAPICallAllocations
52+
53+
test-gopath-v2:
54+
runs-on: ubuntu-latest
55+
strategy:
56+
matrix:
57+
# GOPATH is deprecated in go 1.13.
58+
go-version: [ '1.11.x', '1.12.x']
59+
env:
60+
working-directory: ./v2
61+
62+
steps:
63+
- name: Set up Go
64+
uses: actions/setup-go@v2
65+
with:
66+
go-version: ${{ matrix.go-version }}
67+
- name: Checkout
68+
uses: actions/checkout@v2
69+
- name: Cache go modules
70+
uses: actions/cache@v2
71+
with:
72+
path: |
73+
~/.cache/go-build
74+
~/go/pkg/mod
75+
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
76+
restore-keys: |
77+
${{ runner.os }}-${{ matrix.go-version }}-go-
78+
- name: Set up Cloud SDK
79+
uses: google-github-actions/setup-gcloud@master
80+
- name: Install
81+
working-directory: ${{env.working-directory}}
82+
env:
83+
GO111MODULE: off
84+
run: |
85+
go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v appengine)
86+
go get -u google.golang.org/appengine/v2
87+
gcloud components install app-engine-python app-engine-go cloud-datastore-emulator --quiet
88+
- name: Test gopath v2
89+
working-directory: ${{env.working-directory}}
90+
run: |
91+
export APPENGINE_DEV_APPSERVER=$(which dev_appserver.py)
92+
go test -v -cover -race google.golang.org/appengine/v2/...
93+
# TestAPICallAllocations doesn't run under race detector.
94+
go test -v -cover google.golang.org/appengine/v2/internal/... -run TestAPICallAllocations

.github/workflows/ci.yml

+31-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ jobs:
1212
strategy:
1313
matrix:
1414
go-version: [ '1.11.x', '1.12.x', '1.13.x', '1.14.x', '1.15.x']
15+
1516
steps:
1617
- name: Set up Go
1718
uses: actions/setup-go@v2
1819
with:
1920
go-version: ${{ matrix.go-version }}
21+
- name: Checkout
22+
uses: actions/checkout@v2
2023
- name: Cache go modules
2124
uses: actions/cache@v2
2225
with:
@@ -26,34 +29,58 @@ jobs:
2629
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
2730
restore-keys: |
2831
${{ runner.os }}-${{ matrix.go-version }}-go-
29-
- name: Checkout
30-
uses: actions/checkout@v2
32+
- name: Set up Cloud SDK
33+
uses: google-github-actions/setup-gcloud@master
3134
- name: Install
3235
env:
3336
GO111MODULE: on
3437
run: |
3538
go get .
39+
gcloud components install app-engine-python app-engine-go cloud-datastore-emulator --quiet
3640
- name: Test gomod
41+
env:
42+
GO111MODULE: on
3743
run: |
38-
go test -v -race google.golang.org/appengine/...
44+
export APPENGINE_DEV_APPSERVER=$(which dev_appserver.py)
45+
go test -v -cover -race google.golang.org/appengine/...
46+
# TestAPICallAllocations doesn't run under race detector.
47+
go test -v -cover google.golang.org/appengine/internal/... -run TestAPICallAllocations
48+
3949
test-gopath:
4050
runs-on: ubuntu-latest
4151
strategy:
4252
matrix:
4353
# GOPATH is deprecated in go 1.13.
4454
go-version: [ '1.11.x', '1.12.x']
55+
4556
steps:
4657
- name: Set up Go
4758
uses: actions/setup-go@v2
4859
with:
4960
go-version: ${{ matrix.go-version }}
5061
- name: Checkout
5162
uses: actions/checkout@v2
63+
- name: Cache go modules
64+
uses: actions/cache@v2
65+
with:
66+
path: |
67+
~/.cache/go-build
68+
~/go/pkg/mod
69+
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
70+
restore-keys: |
71+
${{ runner.os }}-${{ matrix.go-version }}-go-
72+
- name: Set up Cloud SDK
73+
uses: google-github-actions/setup-gcloud@master
5274
- name: Install
5375
env:
5476
GO111MODULE: off
5577
run: |
5678
go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v appengine)
79+
go get -u google.golang.org/appengine
80+
gcloud components install app-engine-python app-engine-go cloud-datastore-emulator --quiet
5781
- name: Test gopath
5882
run: |
59-
go test -v -race google.golang.org/appengine/...
83+
export APPENGINE_DEV_APPSERVER=$(which dev_appserver.py)
84+
go test -v -cover -race google.golang.org/appengine/...
85+
# TestAPICallAllocations doesn't run under race detector.
86+
go test -v -cover google.golang.org/appengine/internal/... -run TestAPICallAllocations

CONTRIBUTING.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919

2020
## Running system tests
2121

22-
Download and install the [Go App Engine SDK](https://cloud.google.com/appengine/docs/go/download). Make sure the `go_appengine` dir is in your `PATH`.
23-
2422
Set the `APPENGINE_DEV_APPSERVER` environment variable to `/path/to/go_appengine/dev_appserver.py`.
2523

26-
Run tests with `goapp test`:
24+
Run tests with `go test`:
2725

2826
```
29-
goapp test -v google.golang.org/appengine/...
27+
go test -v google.golang.org/appengine/...
3028
```
3129

3230
## Contributor License Agreements

v2/CONTRIBUTING.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919

2020
## Running system tests
2121

22-
Download and install the [Go App Engine SDK](https://cloud.google.com/appengine/docs/go/download). Make sure the `go_appengine` dir is in your `PATH`.
23-
2422
Set the `APPENGINE_DEV_APPSERVER` environment variable to `/path/to/go_appengine/dev_appserver.py`.
2523

26-
Run tests with `goapp test`:
24+
Run tests with `go test`:
2725

2826
```
29-
goapp test -v google.golang.org/appengine/...
27+
go test -v google.golang.org/appengine/v2/...
3028
```
3129

3230
## Contributor License Agreements

v2/cmd/aefix/ae.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package main
66

77
import (
88
"go/ast"
9-
"path"
109
"strconv"
1110
"strings"
1211
)
@@ -15,7 +14,6 @@ const (
1514
ctxPackage = "golang.org/x/net/context"
1615

1716
newPackageBase = "google.golang.org/"
18-
stutterPackage = false
1917
)
2018

2119
func init() {
@@ -38,10 +36,7 @@ var logMethod = map[string]bool{
3836

3937
// mapPackage turns "appengine" into "google.golang.org/appengine/v2", etc.
4038
func mapPackage(s string) string {
41-
if stutterPackage {
42-
s += "/" + path.Base(s)
43-
}
44-
return newPackageBase + s
39+
return newPackageBase + strings.Replace(s, "appengine", "appengine/v2", 1)
4540
}
4641

4742
func aeFn(f *ast.File) bool {

v2/cmd/aefix/fix.go

+3
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ func usesImport(f *ast.File, path string) (used bool) {
718718
case "<nil>":
719719
// If the package name is not explicitly specified,
720720
// make an educated guess. This is not guaranteed to be correct.
721+
if strings.HasSuffix(path, "/v2") {
722+
path = strings.TrimRight(path, "/v2")
723+
}
721724
lastSlash := strings.LastIndex(path, "/")
722725
if lastSlash == -1 {
723726
name = path

0 commit comments

Comments
 (0)