Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
chokoswitch committed Aug 25, 2023
1 parent 6e57a0a commit cca9ca4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-12
- ubuntu-22.04
- windows-2022
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true

- name: run checks
run: go run mage.go check
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
linters:
enable:
- gofumpt
- goimports
issues:
exclude-rules:
- path: magefiles
linters:
- deadcode
6 changes: 3 additions & 3 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ go 1.20

use (
.
examples/connect
examples/grpc
magefiles
./examples/connect
./examples/grpc
./magefiles
./plugins/grpc
./plugins/proto
)
2 changes: 2 additions & 0 deletions magefiles/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ module github.com/wasilibs/go-re2/magefiles
go 1.18

require github.com/magefile/mage v1.15.0

require golang.org/x/mod v0.12.0 // indirect
3 changes: 3 additions & 0 deletions magefiles/go.sum
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
27 changes: 26 additions & 1 deletion magefiles/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ package main

import (
"fmt"
"golang.org/x/mod/modfile"
"os"

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)

var projects = getProjects()

func Test() error {
return sh.RunV("go", "test", "-v", "./...")
for _, project := range projects {
if err := sh.RunV("go", "test", "-v", fmt.Sprintf("%s/...", project)); err != nil {
return err
}
}
return nil
}

func Format() error {
Expand All @@ -31,3 +40,19 @@ func Lint() error {
func Check() {
mg.SerialDeps(Lint, Test)
}

func getProjects() []string {
goWork, err := os.ReadFile("go.work")
if err != nil {
panic(err)
}
work, err := modfile.ParseWork("go.work", goWork, nil)
if err != nil {
panic(err)
}
var res []string
for _, use := range work.Use {
res = append(res, use.Path)
}
return res
}

0 comments on commit cca9ca4

Please sign in to comment.