Skip to content

Commit

Permalink
Refine actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
monopole committed Aug 2, 2024
1 parent 5155e07 commit e0f1f30
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 178 deletions.
95 changes: 4 additions & 91 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,14 @@ permissions:
contents: read

jobs:
conditional-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
doc: ${{ steps.filter.outputs.doc }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
doc:
- 'site/**'
lint:
name: Lint
needs: conditional-changes
if: needs.conditional-changes.outputs.doc == 'false'
runs-on: [ubuntu-latest]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.work
id: go
- name: Lint
run: make lint
- name: Verify boilerplate
run: make check-license

test-linux:
name: Test Linux
needs: conditional-changes
if: needs.conditional-changes.outputs.doc == 'false'
runs-on: [ubuntu-latest]
steps:
- name: Check out code into the Go module directory
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go 1.x
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.work
id: go
- name: Test all modules
run: make test-unit-non-plugin
env:
KUSTOMIZE_DOCKER_E2E: true

test-macos:
name: Test MacOS
needs: conditional-changes
if: needs.conditional-changes.outputs.doc == 'false'
runs-on: [macos-latest]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.work
id: go
- name: Test all modules
run: make test-unit-non-plugin
env:
KUSTOMIZE_DOCKER_E2E: false # docker not installed on mac

test-windows:
name: Test Windows
needs: conditional-changes
if: needs.conditional-changes.outputs.doc == 'false'
runs-on: [windows-latest]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.work
id: go
- name: Test kyaml
run: go test -cover ./...
working-directory: ./kyaml
- name: Test cmd/config
run: go test -cover ./...
working-directory: ./cmd/config
env:
KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet

# TODO (#4001): replace specific modules above with this once Windows tests are passing.
#- name: Test all modules
# run: make test-unit-non-plugin
# env:
# KUSTOMIZE_DOCKER_E2E: false # docker on windows not working well yet
- name: Test
run: make test
12 changes: 6 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release
name: Release

on:
push:
Expand All @@ -9,16 +9,16 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go 1.x
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.work
id: go
- run: ./releasing/create-release.sh "${tag}"
- name: Release
env:
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: make release
66 changes: 0 additions & 66 deletions .github/workflows/slsa-goreleaser.yml

This file was deleted.

11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ endif
$(MYGOBIN)/mdrip:
releasing/buildWorkspace.sh

# Create a draft release and push it to github.
# Requires go, git, zip, tar, gh (github cli) and env var GH_TOKEN.
# Complains if workspace is dirty, tests fail, tags don't make sense, etc.
.PHONY: release
release: test
release: testClean
(cd releasing; go run . `realpath ..`)

.PHONY: testClean
testClean: clean
go test ./...

.PHONY: test
test: clean
test:
go test ./...

.PHONY: generate
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/print/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewCommand(ldr *loader.FsLoader, p parsren.MdParserRenderer) *cobra.Command
flags := myFlags{}
c := &cobra.Command{
Use: cmdName,
Short: "Prints an extracted shell script",
Short: "Prints extracted, annotated code blocks as a shell script",
Example: utils.PgmName + " " + cmdName + " {path/to/folder}",
RunE: func(cmd *cobra.Command, args []string) error {
fld, err := ldr.LoadTrees(args)
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/raw/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewCommand() *cobra.Command {
flags := myFlags{}
c := &cobra.Command{
Use: cmdName,
Short: "Serves raw files from the given path",
Short: "Serve raw files from the given path",
Example: utils.PgmName + " " + cmdName + " {path/to/folder}",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/serve/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewCommand(ldr *loader.FsLoader, p parsren.MdParserRenderer) *cobra.Command
flags := myFlags{}
c := &cobra.Command{
Use: cmdName,
Short: "Serves a markdown / code-running application at a particular port on localhost.",
Short: "Serve a markdown / code-running application",
Example: utils.PgmName + " " + cmdName + " {path/to/folder}",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/version/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const cmdName = "version"
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: cmdName,
Short: "Shows the version of the program.",
Short: "Print program version",
Example: utils.PgmName + " " + cmdName,
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Printf("%v\n", provenance.GetProvenance())
Expand Down
3 changes: 0 additions & 3 deletions internal/provenance/provenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import (
"github.com/stretchr/testify/assert"
)

const expectedBuildDateFromLdFlag = "2023-01-31T23:38:41Z"
const expectedVersionFromLdFlag = "(test)"

func TestGetProvenance(t *testing.T) {
p := GetProvenance()
assert.Equal(t, DefaultVersion, p.Version)
Expand Down
1 change: 0 additions & 1 deletion internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

const (
PgmName = "mdrip"
Version = "v2.0.0-rc02"
)

var leading = regexp.MustCompile("^[0-9]+_")
Expand Down
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package main

import (
"github.com/monopole/mdrip/v2/internal/commands/version"
"os"

"github.com/monopole/mdrip/v2/internal/commands/gentestdata"
"github.com/monopole/mdrip/v2/internal/commands/print"
"github.com/monopole/mdrip/v2/internal/commands/raw"
"github.com/monopole/mdrip/v2/internal/commands/serve"
"github.com/monopole/mdrip/v2/internal/commands/test"
"github.com/monopole/mdrip/v2/internal/commands/version"
"github.com/monopole/mdrip/v2/internal/loader"
"github.com/monopole/mdrip/v2/internal/parsren/usegold"
"github.com/monopole/mdrip/v2/internal/provenance"
"github.com/monopole/mdrip/v2/internal/utils"
"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand All @@ -24,17 +25,17 @@ func newCommand() *cobra.Command {
c := &cobra.Command{
Use: utils.PgmName + " {path}",
Short: shortHelp,
Long: shortHelp + " (" + utils.Version + ")",
Long: shortHelp + " (" + provenance.GetProvenance().Version + ")",
}
ldr := loader.New(afero.NewOsFs())
p := usegold.NewGParser()
c.AddCommand(
raw.NewCommand(),
version.NewCommand(),
serve.NewCommand(ldr, p),
gentestdata.NewCommand(),
print.NewCommand(ldr, p),
raw.NewCommand(),
serve.NewCommand(ldr, p),
test.NewCommand(ldr, p),
version.NewCommand(),
// "tmux" websocket service disabled until a reasonable use case found.
// the concept works fine on localhost without a websocket.
// tmux.NewCommand(ldr),
Expand Down

0 comments on commit e0f1f30

Please sign in to comment.