mirror of
https://github.com/burrowers/garble.git
synced 2026-04-22 15:47:04 +08:00
start testing on GitHub Actions
No windows yet, because a few portability issues remain.
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
# To prevent CRLF breakages on Windows for fragile files, like testdata.
|
||||||
|
* -text
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
github: mvdan
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
on: [push, pull_request]
|
||||||
|
name: Test
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go-version: [1.13.x]
|
||||||
|
platform: [ubuntu-latest, macos-latest]
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Test
|
||||||
|
run: go test ./...
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
GO111MODULE=on go get mvdan.cc/garble
|
GO111MODULE=on go get mvdan.cc/garble
|
||||||
|
|
||||||
Obfuscate a Go build.
|
Obfuscate a Go build. Requires Go 1.13 or later.
|
||||||
|
|
||||||
garble build [build flags] [packages]
|
garble build [build flags] [packages]
|
||||||
|
|
||||||
|
|||||||
@@ -101,11 +101,16 @@ func main1() int {
|
|||||||
// If we recognise an argument, we're not running within -toolexec.
|
// If we recognise an argument, we're not running within -toolexec.
|
||||||
switch args[0] {
|
switch args[0] {
|
||||||
case "build":
|
case "build":
|
||||||
|
execPath, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
return 1
|
||||||
|
}
|
||||||
goArgs := []string{
|
goArgs := []string{
|
||||||
"build",
|
"build",
|
||||||
"-a",
|
"-a",
|
||||||
"-trimpath",
|
"-trimpath",
|
||||||
"-toolexec=" + os.Args[0],
|
"-toolexec=" + execPath,
|
||||||
}
|
}
|
||||||
goArgs = append(goArgs, args[1:]...)
|
goArgs = append(goArgs, args[1:]...)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/rogpeppe/go-internal/testscript"
|
"github.com/rogpeppe/go-internal/testscript"
|
||||||
@@ -32,12 +33,22 @@ func TestScripts(t *testing.T) {
|
|||||||
if err := os.Mkdir(bindir, 0777); err != nil {
|
if err := os.Mkdir(bindir, 0777); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
binfile := filepath.Join(bindir, "garble")
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
binfile += ".exe"
|
||||||
|
}
|
||||||
if err := os.Symlink(os.Args[0], filepath.Join(bindir, "garble")); err != nil {
|
if err := os.Symlink(os.Args[0], filepath.Join(bindir, "garble")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
env.Vars = append(env.Vars, fmt.Sprintf("PATH=%s%c%s", bindir, filepath.ListSeparator, os.Getenv("PATH")))
|
env.Vars = append(env.Vars, fmt.Sprintf("PATH=%s%c%s", bindir, filepath.ListSeparator, os.Getenv("PATH")))
|
||||||
env.Vars = append(env.Vars, "TESTSCRIPT_COMMAND=garble")
|
env.Vars = append(env.Vars, "TESTSCRIPT_COMMAND=garble")
|
||||||
|
|
||||||
|
// GitHub Actions doesn't define %LocalAppData% on
|
||||||
|
// Windows, which breaks $GOCACHE. Set it ourselves.
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
env.Vars = append(env.Vars, fmt.Sprintf(`LOCALAPPDATA=%s\appdata`, env.WorkDir))
|
||||||
|
}
|
||||||
|
|
||||||
for _, name := range [...]string{
|
for _, name := range [...]string{
|
||||||
"HOME",
|
"HOME",
|
||||||
"USERPROFILE", // $HOME for windows
|
"USERPROFILE", // $HOME for windows
|
||||||
|
|||||||
Vendored
+6
-8
@@ -1,14 +1,12 @@
|
|||||||
# TODO: make this script run on mac and windows
|
|
||||||
|
|
||||||
# Check that the program works as expected without garble.
|
# Check that the program works as expected without garble.
|
||||||
exec go build main.go
|
exec go build main.go
|
||||||
exec ./main
|
exec ./main
|
||||||
cmp stderr main.stderr
|
cmp stderr main.stderr
|
||||||
|
|
||||||
# The default build includes DWARF and the symbol table.
|
# The default build includes DWARF and the symbol table.
|
||||||
exec readelf --section-headers main
|
[!windows] [exec:readelf] exec readelf --section-headers main$exe
|
||||||
stdout 'debug_info'
|
[!windows] [exec:readelf] stdout 'debug_info'
|
||||||
stdout '\.symtab'
|
[!windows] [exec:readelf] stdout '\.symtab'
|
||||||
|
|
||||||
# The default build includes full non-trimmed paths, as well as our names.
|
# The default build includes full non-trimmed paths, as well as our names.
|
||||||
bingrep main$exe ${WORK@R} 'globalVar' 'globalFunc'
|
bingrep main$exe ${WORK@R} 'globalVar' 'globalFunc'
|
||||||
@@ -22,9 +20,9 @@ exec go build -a -trimpath -toolexec=garble main.go
|
|||||||
exec ./main
|
exec ./main
|
||||||
cmp stderr main.stderr
|
cmp stderr main.stderr
|
||||||
|
|
||||||
exec readelf --section-headers main
|
[!windows] [exec:readelf] exec readelf --section-headers main$exe
|
||||||
! stdout 'debug_info'
|
[!windows] [exec:readelf] ! stdout 'debug_info'
|
||||||
! stdout '\.symtab'
|
[!windows] [exec:readelf] ! stdout '\.symtab'
|
||||||
|
|
||||||
! bingrep main$exe ${WORK@R} 'globalVar' 'globalFunc'
|
! bingrep main$exe ${WORK@R} 'globalVar' 'globalFunc'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user