Skip to content

Commit 1bce575

Browse files
committed
CI init
1 parent 9d502a5 commit 1bce575

File tree

8 files changed

+192
-18
lines changed

8 files changed

+192
-18
lines changed

.github/release.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- kind/no-changelog
5+
authors:
6+
- dependabot
7+
categories:
8+
- title: ":boom: Breaking Change"
9+
labels:
10+
- kind/breaking
11+
- title: ":rocket: New Features"
12+
labels:
13+
- kind/feature
14+
- title: ":bug: Bug Fixes"
15+
labels:
16+
- kind/bug
17+
- title: ":broom: Code Refactoring"
18+
labels:
19+
- kind/cleanup
20+
- title: ":memo: Documentation"
21+
labels:
22+
- kind/docs
23+
- title: Other Changes
24+
labels:
25+
- "*"

.github/workflows/integration.yaml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Integration Pipeline
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
branches:
7+
- '**'
8+
9+
jobs:
10+
configure:
11+
name: Preliminary configuration
12+
runs-on: ubuntu-latest
13+
outputs:
14+
commit-ref: ${{ steps.configure.outputs.commit-ref }}
15+
repo-name: ${{ steps.configure.outputs.repo-name }}
16+
steps:
17+
- name: Get the version
18+
id: get_version
19+
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
20+
if: startsWith(github.ref, 'refs/tags/v')
21+
- name: Configure
22+
id: configure
23+
run: |
24+
if [ "${{ steps.get_version.outputs.VERSION }}" != "" ]; then
25+
echo "commit-ref=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT
26+
else
27+
echo "commit-ref=${{ github.sha }}" >> $GITHUB_OUTPUT
28+
fi
29+
echo "repo-name=${{ github.repository }}" >> $GITHUB_OUTPUT
30+
31+
build:
32+
runs-on: ubuntu-latest
33+
needs: [configure]
34+
strategy:
35+
matrix:
36+
goos: [linux, darwin]
37+
goarch: [arm64, amd64]
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
with:
42+
ref: "${{ needs.configure.outputs.commit-ref }}"
43+
repository: "${{ needs.configure.outputs.repo-name }}"
44+
persist-credentials: false
45+
46+
- name: Build
47+
run: |
48+
go build -ldflags="-s -w -X 'main.version=${VERSION}'" -o gowatch-${{ matrix.goos }}-${{ matrix.goarch }} cmd/main.go
49+
env:
50+
CGO_ENABLED: 0
51+
GOOS: ${{ matrix.goos }}
52+
GOARCH: ${{ matrix.goarch }}
53+
VERSION: ${{ needs.configure.outputs.commit-ref }}
54+
55+
- name: Create Archives
56+
run: |
57+
cp gowatch-${{ matrix.goos }}-${{ matrix.goarch }} gowatch
58+
tar -czvf gowatch-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz gowatch LICENSE
59+
60+
- name: Upload
61+
uses: actions/upload-artifact@v3
62+
with:
63+
name: gowatch-${{ matrix.goos }}-${{ matrix.goarch }}
64+
path: ./gowatch-${{ matrix.goos }}-${{ matrix.goarch }}
65+
retention-days: 1
66+
67+
release:
68+
runs-on: ubuntu-latest
69+
needs: [build, configure]
70+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@v3
74+
with:
75+
# The changelog generation requires the entire history
76+
fetch-depth: 0
77+
ref: "${{ needs.configure.outputs.commit-ref }}"
78+
repository: "${{ needs.configure.outputs.repo-name }}"
79+
persist-credentials: false
80+
81+
- uses: actions/download-artifact@v3
82+
with:
83+
path: ./gowatch/
84+
85+
- uses: ncipollo/release-action@v1
86+
with:
87+
artifacts: "./gowatch/**/*"
88+
token: ${{ secrets.CI_TOKEN }}
89+
allowUpdates: true
90+
tag: ${{ needs.configure.outputs.commit-ref }}
91+
name: ${{ needs.configure.outputs.commit-ref }}
92+
prerelease: false

.github/workflows/lint.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Linting
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
golangci:
7+
name: Lint golang files
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
with:
13+
ref: ${{ github.event.pull_request.head.sha }}
14+
repository: ${{github.event.pull_request.head.repo.full_name}}
15+
persist-credentials: false
16+
17+
- name: Setup Go
18+
uses: actions/setup-go@v4
19+
with:
20+
go-version: '1.19'
21+
22+
- name: golangci-lint
23+
uses: golangci/[email protected]
24+
with:
25+
only-new-issues: false
26+
version: v1.52.0
27+
args: --timeout=900s
28+
29+
gomodtidy:
30+
name: Enforce go.mod tidiness
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
with:
37+
ref: "${{ github.event.pull_request.head.sha }}"
38+
repository: ${{github.event.pull_request.head.repo.full_name}}
39+
persist-credentials: false
40+
41+
- name: Setup Go
42+
uses: actions/setup-go@v4
43+
with:
44+
go-version: '1.19'
45+
46+
- name: Execute go mod tidy and check the outcome
47+
working-directory: ./
48+
run: |
49+
go mod tidy
50+
exit_code=$(git diff --exit-code)
51+
exit ${exit_code}
52+
53+
markdownlint:
54+
name: Lint markdown files
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Check out code
58+
uses: actions/checkout@v3
59+
with:
60+
ref: "${{ github.event.pull_request.head.sha }}"
61+
repository: ${{github.event.pull_request.head.repo.full_name}}
62+
persist-credentials: false
63+
- name: Lint markdown files
64+
uses: avto-dev/markdown-lint@v1
65+
with:
66+
config: '.markdownlint.yml'
67+
args: '**/*.md'

.markdownlint.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
default: true
2+
line-length: false
3+
no-inline-html: false

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# gowatch
2-
gowatch is a CLI utility to check a program output and send an output in case a pattern is recognized.
1+
# GoWatch
2+
3+
GoWatch is a CLI utility to check a program output and send a signal in case a pattern is recognized.

cmd/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func main() {
5858
os.Exit(1)
5959
}
6060

61+
//nolint:gosec // This is a command specified by the user
6162
cmd := exec.Command(flag.Arg(0), flag.Args()[1:]...)
6263

6364
w := watch.NewWatcher(cfg, cmd)

makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ endif
99
fmt: gci addlicense
1010
go mod tidy
1111
go fmt ./...
12-
find . -type f -name '*.go' -a ! -name '*zz_generated*' -exec $(GCI) write -s standard -s default -s "prefix(github.com/liqotech/liqo)" {} \;
12+
find . -type f -name '*.go' -a ! -name '*zz_generated*' -exec $(GCI) write -s standard -s default -s "prefix(github.com/cheina97/gowatch)" {} \;
1313
find . -type f -name '*.go' -exec $(ADDLICENSE) -l apache -c "cheina97" -y "2023-$(shell date +%Y)" {} \;
1414

1515
lint: golangci-lint

pkg/check/check.go

-15
This file was deleted.

0 commit comments

Comments
 (0)