From 566a52ebb909359fa6e242a6143b5c2d1591e191 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:00:05 -0600 Subject: [PATCH] chore: adds support for Go 1.22 and 1.23 --- .github/workflows/build.yml | 61 ++++++++++++++--------------------- .github/workflows/release.yml | 8 ++--- CHANGELOG.md | 4 +++ Makefile | 34 ------------------- README.md | 23 +++---------- justfile | 29 +++++++++++++++++ legacy/brew-backup.sh | 54 ------------------------------- legacy/brew-update.sh | 35 -------------------- src/general/general.go | 2 +- 9 files changed, 66 insertions(+), 184 deletions(-) delete mode 100644 Makefile create mode 100644 justfile delete mode 100644 legacy/brew-backup.sh delete mode 100755 legacy/brew-update.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34d4781..8a4a967 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,35 +3,39 @@ name: build on: [push, pull_request] jobs: - shellcheck: - name: Shellcheck - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@1.0.0 - with: - scandir: 'legacy' lint: runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 - name: Run Golangci Linter - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60.1 test: - name: Test with Coverage + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + go: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22', '1.23'] + steps: + - uses: actions/checkout@v4 + - uses: extractions/setup-just@v2 + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + - name: Build and test + run: just build test + coverage: runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v5 + - uses: actions/checkout@v4 + - uses: extractions/setup-just@v2 + - uses: actions/setup-go@v5 with: - go-version: '1.21' - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Run unit tests - run: make coverage + go-version: '1.23' + - name: Generate coverage report + run: just coverage - name: Install goveralls if: github.ref == 'refs/heads/main' env: @@ -42,18 +46,3 @@ jobs: env: COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: goveralls -coverprofile=covprofile -service=github - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - go: ['1.16', '1.17', '1.18', '1.19', '1.20', '1.21'] - steps: - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go }} - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Build - run: go build -o dist/alchemist diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd048a4..b3fac1c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,12 +9,10 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.23' - name: Run goreleaser uses: goreleaser/goreleaser-action@v2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ed19d6..09dff66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v3.3.0 (2024-08-22) + +- Adds support for Go `1.22` and `1.23` + ## v3.2.0 (2022-05-21) - Adds a `--greedy` CLI flag so casks can be updated even if they have a UI "auto-update" feature (helps keep Homebrew app versions synced better with what they actually are) diff --git a/Makefile b/Makefile deleted file mode 100644 index c44462a..0000000 --- a/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -PROJECT_NAME := alchemist -PROJECT_PATH := $$(go env GOPATH)/bin/$(PROJECT_NAME) -DIST_PATH := dist - -## help - Display help about make targets for this Makefile -help: - @cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t - -## build - Build the project -build: - go build -o $(DIST_PATH)/$(PROJECT_NAME) - -## clean - Clean the project -clean: - rm -rf - rm $(DIST_PATH)/$(PROJECT_PATH) - -## coverage - Get test coverage and open it in a browser -coverage: - go clean -testcache && go test ./... -coverprofile=covprofile && go tool cover -html=covprofile - -## install - Install globally from source -install: - go build -o $(PROJECT_PATH) - -## lint - Lint the project -lint: - golangci-lint run - -## test - Test the project -test: - go clean -testcache && go test ./... - -.PHONY: help build clean coverage install lint test diff --git a/README.md b/README.md index 16ea4cd..86c8ed2 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Alchemist saves logs to `~/alchemist/update/alchemist-update.log`. Logs by defau Scripts generated from the backup functionality of Alchemist live at `~/alchemist/backup`. Simply run `brew bundle --file path/to/Brewfile` or `path/to/restore-choco-packages.bat` to restore your packages. -``` +```text Usage: alchemist --update @@ -88,22 +88,7 @@ Options: ## Development -```bash -# Build the project -make build - -# Install the project globally from source -make install - -# Clean the executables -make clean - -# Test the project -make test - -## Get test coverage -make coverage - -# Lint the project (requires golangci-lint be installed) -make lint +```shell +# Get a comprehensive list of development tools +just --list ``` diff --git a/justfile b/justfile new file mode 100644 index 0000000..758102d --- /dev/null +++ b/justfile @@ -0,0 +1,29 @@ +PROJECT_NAME := "alchemist" +GO_BIN := `go env GOPATH` / "bin" +DIST_PATH := "dist" + +# Build the project +build: + go build -o {{DIST_PATH}}/{{PROJECT_NAME}} + +# Clean the project +clean: + rm -rf vendor + rm {{DIST_PATH}} + +# Get test coverage and open it in a browser +coverage: + go clean -testcache && go test ./... -coverprofile=covprofile && go tool cover -html=covprofile + +# Install globally from source +install: + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b {{GO_BIN}} v1.60.1 + go mod vendor + +# Lint the project +lint: + {{GO_BIN}}/golangci-lint run + +# Test the project +test: + go clean -testcache && go test ./... diff --git a/legacy/brew-backup.sh b/legacy/brew-backup.sh deleted file mode 100644 index 9dee13b..0000000 --- a/legacy/brew-backup.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# Backup your Homebrew packages and casks to installable scripts. - -main() { - BREW_BACKUP_LOCATION=${1:-"$HOME/brew-backup"} - PACKAGE_SCRIPT_LOCATION="$BREW_BACKUP_LOCATION/restore-brew-packages.sh" - CASK_SCRIPT_LOCATION="$BREW_BACKUP_LOCATION/restore-brew-casks.sh" - - echo -e "Backing up Homebrew packages and casks...\n" - setup_location_folder - create_restore_scripts - brew_backup - make_packages_installable - - make_script_executable "$PACKAGE_SCRIPT_LOCATION" - make_script_executable "$CASK_SCRIPT_LOCATION" - - echo "Homebrew package restore script saved to: $PACKAGE_SCRIPT_LOCATION" - echo "Homebrew cask restore script saved to: $CASK_SCRIPT_LOCATION" -} - -setup_location_folder() { - # If the location folder does not exists, set it up - mkdir -p "$BREW_BACKUP_LOCATION" -} - -make_script_executable() { - # Make script executable - chmod 755 "$1" -} - -create_restore_scripts() { - # Create the empty restore scripts with a shebang - local timestamp - timestamp=$(date +%Y-%m-%d:%H-%M-%S) - echo -e "#!/bin/bash\n# Backed up: $timestamp" > "$PACKAGE_SCRIPT_LOCATION" - echo -e "#!/bin/bash\n# Backed up: $timestamp" > "$CASK_SCRIPT_LOCATION" -} - -brew_backup() { - # Populate Brew data to a script file - brew list --formula >> "$PACKAGE_SCRIPT_LOCATION" - brew list --cask >> "$CASK_SCRIPT_LOCATION" -} - -make_packages_installable() { - # Make scripts installable by appending the brew commands to the package names - # NOTE: This usage of "sed" assumes the BSD version is installed - sed -i "" '3,$s/^/brew install /' "$PACKAGE_SCRIPT_LOCATION" - sed -i "" '3,$s/^/brew cask install /' "$CASK_SCRIPT_LOCATION" -} - -main "$1" diff --git a/legacy/brew-update.sh b/legacy/brew-update.sh deleted file mode 100755 index 044ff3e..0000000 --- a/legacy/brew-update.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -main() { - LOCATION=${1:-"$HOME/brew-update"} - LOG_LIFE=${2:-"90"} - - make_directories - brew_update - clean_logs -} - -make_directories() { - # Create project directories if they do not exist - mkdir -p "$LOCATION" -} - -brew_update() { - # Update, upgrade, clean, and doctor your Homebrew instance - local date - date=$(date +'%Y-%m-%d') - { - brew update - brew upgrade - brew upgrade --cask - brew cleanup - brew doctor - } 2>&1 | tee "$LOCATION"/"$date".log -} - -clean_logs() { - # If logs are older than the log life, delete them - find "$LOCATION"/logs -mindepth 1 -mtime +"$LOG_LIFE" -delete -} - -main "$1" "$2" diff --git a/src/general/general.go b/src/general/general.go index 5c509a6..86f7ece 100644 --- a/src/general/general.go +++ b/src/general/general.go @@ -19,7 +19,7 @@ func RunCommand(cmdContext mockcmd.ExecContext, command string, args []string) ( cmd.Stderr = &stderr err := cmd.Run() if err != nil { - return nil, fmt.Errorf(fmt.Sprint(err) + ": " + stderr.String()) + return nil, fmt.Errorf("%v: %s", err, stderr.String()) } return &out, nil