Skip to content

Commit 96e3717

Browse files
authored
github/workflows: fix branch name and refactoring workflows (#145)
* github/workflows: fix branch name and refactoring workflows * nvim: fix testcase for v0.7.2
1 parent 1e22633 commit 96e3717

File tree

4 files changed

+43
-63
lines changed

4 files changed

+43
-63
lines changed

.github/workflows/benchmark.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,27 @@ defaults:
1414

1515
jobs:
1616
benchmark:
17-
strategy:
18-
matrix:
19-
os:
20-
- ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
21-
go-version:
22-
- 1.19.x
23-
24-
runs-on: ${{ matrix.os }}
17+
runs-on: ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
2518

2619
steps:
2720
- name: Set flag environment variable
2821
run: |
2922
echo "OS=$(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
3023
echo "GO_VERSION=$(echo ${{ matrix.go-version }} | cut -d. -f-2)" >> $GITHUB_ENV
3124
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
3228
- name: Install Go
3329
uses: actions/setup-go@v3
3430
with:
35-
go-version: ${{ matrix.go-version }}
36-
37-
- name: Checkout code
38-
uses: actions/checkout@v3
31+
go-version: '1.19.x'
3932

4033
- name: Install nvim binary
4134
uses: rhysd/action-setup-vim@v1
42-
if: steps.cache-nvim.outputs.cache-hit != 'true'
4335
with:
4436
neovim: true
45-
version: v0.7.0
37+
version: v0.7.2
4638

4739
- name: Run Benchmark
4840
run: |

.github/workflows/codeql.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,38 @@ name: "CodeQL"
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
pull_request:
8-
branches:
9-
- master
108
schedule:
119
- cron: '0 20 * * *'
1210

1311
jobs:
1412
analyze:
1513
name: Analyze
16-
runs-on:
17-
- ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
14+
runs-on: ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
1815

1916
permissions:
2017
actions: read
2118
contents: read
2219
security-events: write
2320

24-
strategy:
25-
fail-fast: false
26-
2721
steps:
2822
- name: Checkout repository
2923
uses: actions/checkout@v3
3024

25+
- name: Set up Go
26+
uses: actions/setup-go@v3
27+
with:
28+
go-version: '1.19.x'
29+
3130
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@v1
31+
uses: github/codeql-action/init@v2
3332
with:
3433
languages: 'go'
3534

3635
- name: Perform CodeQL Analysis
37-
uses: github/codeql-action/analyze@v1
36+
uses: github/codeql-action/analyze@v2
37+
env:
38+
# hack for fetch dependencies when failed to go-autobuilder 'make' command
39+
# https://github.com/github/codeql-go/blob/b953fe39c2cb/extractor/cli/go-autobuilder/go-autobuilder.go#L409
40+
CODEQL_EXTRACTOR_GO_BUILD_COMMAND: 'true'

.github/workflows/test.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ name: Test
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
pull_request:
8-
branches:
9-
- master
108
release:
119
types:
1210
- published
@@ -30,7 +28,7 @@ jobs:
3028
- 1.18.x
3129
- 1.19.x
3230
neovim-version:
33-
- v0.7.0
31+
- v0.7.2
3432
- nightly
3533
fail-fast: false
3634

@@ -57,11 +55,6 @@ jobs:
5755
neovim: true
5856
version: ${{ matrix.neovim-version }}
5957

60-
- name: gofmt
61-
if: matrix.go-version == '1.19.x' && env.OS != 'windows'
62-
run: |
63-
diff -u <(echo -n) <(gofmt -s -d .)
64-
6558
- name: go vet
6659
run: |
6760
go vet ./...

nvim/api_test.go

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,24 @@ func parseVersion(tb testing.TB, version string) (major, minor, patch int64) {
5959
return major, minor, patch
6060
}
6161

62-
func isSkipVersion(tb testing.TB, version string) bool {
62+
func versionIs(tb testing.TB, version string) bool {
6363
major, minor, patch := parseVersion(tb, version)
64-
if nvimVersion.Major < major || nvimVersion.Minor < minor || nvimVersion.Patch < patch {
64+
if nvimVersion.Major <= major && nvimVersion.Minor <= minor && nvimVersion.Patch <= patch {
6565
return true
6666
}
6767

6868
return false
6969
}
7070

7171
func skipVersion(tb testing.TB, version string) {
72-
if isSkipVersion(tb, version) {
72+
if versionIs(tb, version) {
7373
const skipFmt = "run this test %s or higher neovim version: current neovim version %s"
7474
tb.Skipf(skipFmt, version, nvimVersion)
7575
}
7676
}
7777

7878
func skipBetweenVersion(tb testing.TB, low, high string) {
79-
if isSkipVersion(tb, low) || !isSkipVersion(tb, high) {
79+
if versionIs(tb, low) || versionIs(tb, high) {
8080
const skipFmt = "run this test between %s to %s neovim version: current version: %s"
8181
tb.Skipf(skipFmt, low, high, nvimVersion)
8282
}
@@ -1137,7 +1137,7 @@ func testWindow(v *Nvim) func(*testing.T) {
11371137
}
11381138

11391139
t.Run("WindowBuffer", func(t *testing.T) {
1140-
skipVersion(t, "v0.6.0")
1140+
skipVersion(t, "v0.7.0")
11411141

11421142
gotBuf, err := v.WindowBuffer(Window(0))
11431143
if err != nil {
@@ -1374,7 +1374,7 @@ func testWindow(v *Nvim) func(*testing.T) {
13741374
}
13751375

13761376
t.Run("WindowBuffer", func(t *testing.T) {
1377-
skipVersion(t, "v0.6.0")
1377+
skipVersion(t, "v0.7.0")
13781378

13791379
b := v.NewBatch()
13801380

@@ -2190,7 +2190,7 @@ func testCommand(v *Nvim) func(*testing.T) {
21902190
}
21912191
for name, tt := range tests {
21922192
t.Run(path.Join(name, "Nvim"), func(t *testing.T) {
2193-
skipVersion(t, "v0.7.0")
2193+
skipVersion(t, "v0.8.0")
21942194

21952195
if err := v.CreateUserCommand(tt.name, tt.command, tt.opts); err != nil {
21962196
t.Fatal(err)
@@ -2211,7 +2211,7 @@ func testCommand(v *Nvim) func(*testing.T) {
22112211
})
22122212

22132213
t.Run(path.Join(name, "Batch"), func(t *testing.T) {
2214-
skipVersion(t, "v0.7.0")
2214+
skipVersion(t, "v0.8.0")
22152215

22162216
b := v.NewBatch()
22172217

@@ -2256,7 +2256,7 @@ func testCommand(v *Nvim) func(*testing.T) {
22562256
}
22572257
for name, tt := range tests {
22582258
t.Run(path.Join(name, "Nvim"), func(t *testing.T) {
2259-
skipVersion(t, "v0.7.0")
2259+
skipVersion(t, "v0.8.0")
22602260

22612261
if err := v.CreateBufferUserCommand(Buffer(0), tt.name, tt.command, tt.opts); err != nil {
22622262
t.Fatal(err)
@@ -2277,7 +2277,7 @@ func testCommand(v *Nvim) func(*testing.T) {
22772277
})
22782278

22792279
t.Run(path.Join(name, "Batch"), func(t *testing.T) {
2280-
skipVersion(t, "v0.7.0")
2280+
skipVersion(t, "v0.8.0")
22812281

22822282
b := v.NewBatch()
22832283

@@ -2867,7 +2867,7 @@ func testKey(v *Nvim) func(*testing.T) {
28672867
})
28682868

28692869
t.Run("KeyMap", func(t *testing.T) {
2870-
skipBetweenVersion(t, "v0.6.0", "v0.8.0")
2870+
skipBetweenVersion(t, "v0.7.0", "v0.8.0")
28712871

28722872
mode := "n"
28732873
if err := v.SetKeyMap(mode, "y", "yy", make(map[string]bool)); err != nil {
@@ -3209,7 +3209,7 @@ func testKey(v *Nvim) func(*testing.T) {
32093209
})
32103210

32113211
t.Run("KeyMap", func(t *testing.T) {
3212-
skipBetweenVersion(t, "v0.6.0", "v0.8.0")
3212+
skipBetweenVersion(t, "v0.7.0", "v0.8.0")
32133213

32143214
b := v.NewBatch()
32153215

@@ -4742,7 +4742,7 @@ func testOptions(v *Nvim) func(*testing.T) {
47424742
for name, tt := range tests {
47434743
t.Run("Nvim/"+name, func(t *testing.T) {
47444744
if name == "hidden" {
4745-
skipVersion(t, "v0.6.0")
4745+
skipVersion(t, "v0.7.0")
47464746
}
47474747

47484748
got, err := v.OptionInfo(tt.name)
@@ -4758,7 +4758,7 @@ func testOptions(v *Nvim) func(*testing.T) {
47584758
for name, tt := range tests {
47594759
t.Run("Batch/"+name, func(t *testing.T) {
47604760
if name == "hidden" {
4761-
skipVersion(t, "v0.6.0")
4761+
skipVersion(t, "v0.7.0")
47624762
}
47634763

47644764
b := v.NewBatch()
@@ -4876,7 +4876,7 @@ func testOptionsInfo(v *Nvim) func(*testing.T) {
48764876
for name, tt := range tests {
48774877
t.Run("Nvim/"+name, func(t *testing.T) {
48784878
if name == "hidden" {
4879-
skipVersion(t, "v0.6.0")
4879+
skipVersion(t, "v0.7.0")
48804880
}
48814881

48824882
got, err := v.OptionInfo(tt.name)
@@ -4892,7 +4892,7 @@ func testOptionsInfo(v *Nvim) func(*testing.T) {
48924892
for name, tt := range tests {
48934893
t.Run("Batch/"+name, func(t *testing.T) {
48944894
if name == "hidden" {
4895-
skipVersion(t, "v0.6.0")
4895+
skipVersion(t, "v0.7.0")
48964896
}
48974897

48984898
b := v.NewBatch()
@@ -4937,7 +4937,7 @@ func testOptionsValue(v *Nvim) func(*testing.T) {
49374937
}
49384938
for name, tt := range tests {
49394939
t.Run(path.Join(name, "Nvim"), func(t *testing.T) {
4940-
skipVersion(t, "v0.7.0")
4940+
skipVersion(t, "v0.8.0")
49414941

49424942
var result interface{}
49434943
if err := v.OptionValue(tt.name, tt.opts, &result); err != nil {
@@ -4967,7 +4967,7 @@ func testOptionsValue(v *Nvim) func(*testing.T) {
49674967

49684968
for name, tt := range tests {
49694969
t.Run(path.Join(name, "Batch"), func(t *testing.T) {
4970-
skipVersion(t, "v0.7.0")
4970+
skipVersion(t, "v0.8.0")
49714971

49724972
b := v.NewBatch()
49734973

@@ -5669,19 +5669,15 @@ func testAutocmd(v *Nvim) func(*testing.T) {
56695669
{
56705670
ID: 0,
56715671
Group: augID,
5672-
Desc: `<vim function: echomsg 'Hello Autocmd'>`,
56735672
Event: `User`,
5674-
Command: `<vim function: echomsg 'Hello Autocmd'>`,
56755673
Once: false,
56765674
Pattern: `AutocmdTest`,
56775675
BufLocal: false,
56785676
Buffer: 0,
56795677
},
56805678
}
5681-
switch nvimVersion.Minor {
5682-
case 8:
5683-
want[0].Desc = ""
5684-
want[0].Command = ""
5679+
if versionIs(t, "v0.7.2") {
5680+
want[0].Command = `<vim function: echomsg 'Hello Autocmd'>`
56855681
}
56865682

56875683
args := map[string]interface{}{
@@ -5783,19 +5779,15 @@ func testAutocmd(v *Nvim) func(*testing.T) {
57835779
{
57845780
ID: 0,
57855781
Group: augID,
5786-
Desc: `<vim function: echomsg 'Hello Autocmd'>`,
57875782
Event: `User`,
5788-
Command: `<vim function: echomsg 'Hello Autocmd'>`,
57895783
Once: false,
57905784
Pattern: `AutocmdTest`,
57915785
BufLocal: false,
57925786
Buffer: 0,
57935787
},
57945788
}
5795-
switch nvimVersion.Minor {
5796-
case 8:
5797-
want[0].Desc = ""
5798-
want[0].Command = ""
5789+
if versionIs(t, "v0.7.2") {
5790+
want[0].Command = `<vim function: echomsg 'Hello Autocmd'>`
57995791
}
58005792

58015793
args := map[string]interface{}{

0 commit comments

Comments
 (0)