diff --git a/.github/workflows/aio.yml b/.github/workflows/aio.yml deleted file mode 100644 index 0addef9..0000000 --- a/.github/workflows/aio.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: AllInOne - -on: - push: - paths-ignore: - - '**.md' - pull_request: - paths-ignore: - - '**.md' - schedule: - - cron: 0 0 * * 5 - -jobs: - plugin_test: - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - runs-on: ${{ matrix.os }} - steps: - - name: asdf_plugin_test - uses: asdf-vm/actions/plugin-test@v1 - with: - command: ark version - - lint_and_tests: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Run the sh-checker - uses: luizm/action-sh-checker@v0.1.12 - env: - GITHUB_TOKEN: ${{ github.token }} - #SHELLCHECK_OPTS: -e SC1004 # Optional: exclude some shellcheck warnings. - SHFMT_OPTS: -i 2 # Optional: pass arguments to shfmt. - with: - sh_checker_comment: true - - name: Install asdf - run: | - git clone https://github.com/asdf-vm/asdf.git $HOME/asdf - - - name: Install bats - run: | - sudo apt-get install bats - bats --version - - - name: Test plugin with bats - run: | - . $HOME/asdf/asdf.sh - asdf plugin-add arkade $GITHUB_WORKSPACE - bats test diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..98f2afb --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,25 @@ +name: Test Plugin + +on: + pull_request: + push: + schedule: + - cron: 0 1 * * MON + +jobs: + test-plugin: + name: Test Plugin + + strategy: + fail-fast: false + matrix: + os: + - macos-latest + - ubuntu-latest + + runs-on: ${{ matrix.os }} + + steps: + - uses: asdf-vm/actions/plugin-test@v2 + with: + command: ark version diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..740ab65 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +SRCFILES = $(shell git ls-files "bin/**") +SHFMT_BASE_FLAGS = -s -i 2 -ci + +format: + shfmt -w $(SHFMT_BASE_FLAGS) $(SRCFILES) +.PHONY: format + +format-check: + shfmt -d $(SHFMT_BASE_FLAGS) $(SRCFILES) +.PHONY: format-check + +lint: + shellcheck $(SRCFILES) +.PHONY: lint diff --git a/README.md b/README.md index cbe1c00..79cefa2 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,7 @@ # asdf-arkade -![AllInOne](https://github.com/asdf-community/asdf-arkade/workflows/AllInOne/badge.svg) [![GitHub license](https://img.shields.io/github/license/asdf-community/asdf-arkade?style=plastic)](https://github.com/asdf-community/asdf-arkade/blob/master/LICENSE) -## Build History - -[![Build history](https://buildstats.info/github/chart/asdf-community/asdf-arkade?branch=master)](https://github.com/asdf-community/asdf-arkade/actions) - ## arkade @@ -27,7 +22,4 @@ This source code has been generated with : ```bash cookiecutter --overwrite-if-exists --directory plugins/arkade --no-input https://github.com/looztra/cookiecutter-asdf-plugin - ``` - - diff --git a/bin/install b/bin/install index 7c631c3..bbeecca 100755 --- a/bin/install +++ b/bin/install @@ -39,11 +39,11 @@ function log() { line="[$(date '+%F %T')] $level: $*" if [ -t 2 ]; then case "$level" in - INFO) code=36 ;; - DEBUG) code=35 ;; - WARN) code=33 ;; - ERROR) code=31 ;; - *) code=37 ;; + INFO) code=36 ;; + DEBUG) code=35 ;; + WARN) code=33 ;; + ERROR) code=31 ;; + *) code=37 ;; esac echo -e "\e[${code}m${line} \e[94m(${FUNCNAME[1]})\e[0m" else @@ -53,7 +53,7 @@ function log() { # from https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash function vercomp() { - if [[ "$1" == "$2" ]]; then + if [[ $1 == "$2" ]]; then return 0 fi local IFS=. @@ -91,14 +91,14 @@ install_tool() { local bin_install_path="$install_path/bin" local full_path_to_binary="$bin_install_path/${binary_name}" local full_path_to_alt_binary - if [[ -n "$binary_alt_name" || "$binary_alt_name" == "$NO_BINARY_ALTNAME" ]]; then + if [[ -n $binary_alt_name || $binary_alt_name == "$NO_BINARY_ALTNAME" ]]; then full_path_to_alt_binary="$bin_install_path/${binary_alt_name}" fi local download_url local download_target_file local download_sub_path_dir - if [[ "$install_type" != "version" ]]; then + if [[ $install_type != "version" ]]; then log ERROR "Install of type [$install_type] not supported" fi @@ -116,10 +116,10 @@ install_tool() { log INFO "Cleaning previous binaries if any" rm -f "$full_path_to_binary" 2>/dev/null || true - if [[ -n "$binary_alt_name" ]]; then + if [[ -n $binary_alt_name ]]; then rm -f "$full_path_to_alt_binary" 2>/dev/null || true fi - if [[ "$downloaded_file_is_not_an_archive" != "true" ]]; then + if [[ $downloaded_file_is_not_an_archive != "true" ]]; then log INFO "Extracting archive" tar xpf "$download_target_file" -C "$tmp_download_dir" else @@ -129,7 +129,7 @@ install_tool() { log INFO "Copying binaries" cp "$(get_binary_path_in_archive "${tmp_download_dir}" "${binary_name}" "${version}" "${platform}")" "${full_path_to_binary}" chmod +x "${full_path_to_binary}" - if [[ -n "$binary_alt_name" ]]; then + if [[ -n $binary_alt_name ]]; then cp "${full_path_to_binary}" "${full_path_to_alt_binary}" chmod +x "${full_path_to_alt_binary}" fi @@ -159,9 +159,9 @@ get_platform() { get_platform_custom() { local operating_system operating_system=$(uname | tr '[:upper:]' '[:lower:]') - if [[ "$operating_system" == "linux" ]]; then + if [[ $operating_system == "linux" ]]; then echo "" - elif [[ "$operating_system" == "darwin" ]]; then + elif [[ $operating_system == "darwin" ]]; then echo "-darwin" else log ERROR "Unsupported value for operating_system [$operating_system]" @@ -208,6 +208,6 @@ get_download_url() { } # -readonly _tmp_download_dir="$(mktemp -d -t 'asdf_XXXXXXXX')" +_tmp_download_dir="$(mktemp -d -t 'asdf_XXXXXXXX')" trap 'rm -rf "${_tmp_download_dir}"' EXIT install_tool "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" "$_tmp_download_dir" "$g_binary_name" "$g_binary_altname" "$g_downloaded_file_is_not_an_archive" diff --git a/bin/list-all b/bin/list-all index 83685bd..f1607bf 100755 --- a/bin/list-all +++ b/bin/list-all @@ -15,6 +15,6 @@ function sort_versions() { } # Fetch all tag names, and get only second column. Then remove all unnecesary characters. -versions=$(eval "$cmd" | grep -oE "tag_name\": *\".{1,15}\"," | sed 's/tag_name\": *\"//;s/\",//' | sed 's/^v//' | sort_versions) +versions=$(eval "$cmd" | grep -oE 'tag_name": *".{1,15}",' | sed 's/tag_name\": *\"//;s/\",//' | sed 's/^v//' | sort_versions) # shellcheck disable=SC2086 echo $versions diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..dd7d50a --- /dev/null +++ b/renovate.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:base", "schedule:daily"] +} diff --git a/test/default.bats b/test/default.bats deleted file mode 100644 index 3a3bded..0000000 --- a/test/default.bats +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bats - -@test "can list all" { - asdf list all arkade -} - -@test "can install latest" { - asdf install arkade latest -}