-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: first cut of running tests on macOS
Get a simple version of our tests running against "latest" Go and "latest" Vim on macOS. We can update this to be more specific later. For now neither capture nor upload any artefacts post build. To install Vim we follow the approach laid out in: https://blog.myitcv.io/2020/02/04/portable-ci-cd-with-pure-go-github-actions.html to create a local pure Go GitHub action to install Vim, rather than relying on a third-party NodeJS action. Updates #481
- Loading branch information
Showing
10 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### `github.com/myitcv/action-setup-vim` | ||
|
||
`setupvim` is a pure Go GitHub Action for install Vim on various platforms. It is a work-in-progress. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: 'Setup Vim' | ||
description: 'Setup Vim in your workflow' | ||
inputs: | ||
version: | ||
description: > | ||
Version of Vim to install. Valid values are git refs (e.g. 'master', a branch name or commit hash) | ||
or version tags (e.g. 'v8.2.0126') | ||
required: false | ||
default: 'master' | ||
|
||
runs: | ||
using: 'node12' | ||
main: 'index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/govim/govim/githubactions/github/actions/setupvim | ||
|
||
go 1.14 | ||
|
||
require github.com/sethvargo/go-githubactions v0.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/sethvargo/go-githubactions v0.1.1 h1:u75rV0C+AvNjEUE4maSN844/U5eiy9Rlc3ahOU4EAfE= | ||
github.com/sethvargo/go-githubactions v0.1.1/go.mod h1:ugCoIFQjs7HxIwwYiY7ty6H9T+7Z4ey481HxqA3VRKE= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
|
||
const spawn = require("child_process").spawn; | ||
|
||
async function run() { | ||
var args = Array.prototype.slice.call(arguments); | ||
const cmd = spawn(args[0], args.slice(1), { | ||
stdio: "inherit", | ||
cwd: __dirname | ||
}); | ||
const exitCode = await new Promise((resolve, reject) => { | ||
cmd.on("close", resolve); | ||
}); | ||
if (exitCode != 0) { | ||
process.exit(exitCode); | ||
} | ||
} | ||
|
||
(async function() { | ||
const path = require("path"); | ||
await run("go", "run", "."); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// setupvim is a pure Go GitHub Action for install Vim on various platforms. It | ||
// is a work-in-progress. | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"runtime" | ||
"strconv" | ||
|
||
"github.com/sethvargo/go-githubactions" | ||
) | ||
|
||
const debug = true | ||
|
||
func main() { | ||
os.Exit(main1()) | ||
} | ||
|
||
func main1() int { | ||
if err := mainerr(); err != nil { | ||
switch err := err.(type) { | ||
case runCmdErr: | ||
ee := err.error.(*exec.ExitError) | ||
return ee.ProcessState.ExitCode() | ||
default: | ||
fmt.Fprintln(os.Stderr, err) | ||
return 1 | ||
} | ||
} | ||
return 0 | ||
} | ||
|
||
func mainerr() error { | ||
td := tempDir("", "") | ||
if !debug { | ||
defer os.RemoveAll(td) | ||
} | ||
version := "master" | ||
if v := githubactions.GetInput("version"); v != "" { | ||
version = v | ||
} | ||
cmd("git", "clone", "-q", "--depth=1", "--single-branch", "--branch", version, "https://github.com/vim/vim", td).run() | ||
id := tempDir("", "") | ||
if !debug { | ||
defer os.RemoveAll(id) | ||
} | ||
cmd("./configure", "--prefix="+id, "--with-features=huge", "--enable-fail-if-missing").runInDir(td) | ||
cmd("make", "-j", strconv.Itoa(runtime.NumCPU())).runInDir(td) | ||
cmd("make", "install").runInDir(td) | ||
bin := filepath.Join(id, "bin") | ||
githubactions.SetEnv("PATH", bin+string(os.PathListSeparator)+os.Getenv("PATH")) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
type command struct { | ||
cmd *exec.Cmd | ||
} | ||
|
||
type runCmdErr struct { | ||
error | ||
} | ||
|
||
func cmd(cmdname string, args ...string) *command { | ||
cmd := exec.Command(cmdname, args...) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
return &command{ | ||
cmd: cmd, | ||
} | ||
} | ||
|
||
func (c *command) run() { | ||
format := "> " | ||
wd, err := os.Getwd() | ||
check(err, "failed to get working directory: %v", err) | ||
runDir := wd | ||
if d := c.cmd.Dir; d != "" { | ||
rd, err := filepath.Abs(d) | ||
check(err, "failed to make %v absolute: %v", d, err) | ||
runDir = rd | ||
} | ||
if wd != runDir { | ||
format += fmt.Sprintf("cd %v; ", runDir) | ||
} | ||
format += "%v\n" | ||
fmt.Printf(format, strings.Join(c.cmd.Args, " ")) | ||
if err := c.cmd.Run(); err != nil { | ||
panic(runCmdErr{err}) | ||
} | ||
} | ||
|
||
func (c *command) runInDir(dir string) { | ||
c.cmd.Dir = dir | ||
c.run() | ||
} | ||
|
||
func tempDir(dir, pattern string) string { | ||
td, err := ioutil.TempDir(dir, pattern) | ||
check(err, "failed to create temp dir: %v", err) | ||
return td | ||
} | ||
|
||
func check(err error, format string, args ...interface{}) { | ||
if err != nil { | ||
panic(fmt.Errorf(format, args...)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
func installVim() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters