Skip to content

Commit

Permalink
add CI github action
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-codes committed Sep 27, 2024
1 parent 7a30129 commit bad8472
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
go: ["stable", "oldstable"]
timeout-minutes: 5

steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- run: go version
- run: go mod verify
- name: go mod tidy
run: |
go mod tidy
git diff --exit-code
- run: go vet ./...
- name: go fmt
run: |
go fmt ./...
git diff --exit-code
- name: go test
run: go test -v -count=1 -shuffle=on ./...
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run: {}
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.DEFAULT_GOAL = check
.PHONY: FORCE

CC = /usr/local/musl/bin/musl-gcc
GOFLAGS = -ldflags '-linkmode external -extldflags "-static"'
OUTDIR = bin
TESTGEN_BINARY = $(OUTDIR)/testgen

build-testgen: $(TESTGEN_BINARY)
.PHONY: build-testgen

clean:
rm -f $(TESTGEN_BINARY)
.PHONY: clean

fmt:
go fmt ./...
.PHONY: fmt

vet:
go vet ./...
.PHONY: vet

test:
go test -v -p=4 ./...
.PHONY: test

check: fmt vet test
.PHONY: check

$(TESTGEN_BINARY): FORCE
@mkdir -p $(OUTDIR)
CC=$(CC) go build $(GOFLAGS) -o $@ ./cmd/testgen/main.go

deps: FORCE
go mod verify
go mod tidy

all: clean deps
.PHONY: all
2 changes: 2 additions & 0 deletions cmd/testgen/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

package main

import (
Expand Down
4 changes: 4 additions & 0 deletions internal/testgen/cgetopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ func cGetOpt(cArgc C.int, cArgv []*C.char, optstring string, longoptstring strin
name := parseName(cLongoptions, char, optopt, flag)
mutArgs := copyCArgv(cArgc, cArgv)

if err == "-1" {
optarg = ""
}

if (err == "?" || err == ":") && (char == "" && name == "") {
val := strings.TrimPrefix(curr_arg, "-")
val = strings.TrimPrefix(val, "-")
Expand Down

0 comments on commit bad8472

Please sign in to comment.