From 87d0d0688dedd13decf21bebd5953b5292594d34 Mon Sep 17 00:00:00 2001 From: cpanato Date: Tue, 30 Apr 2024 11:16:42 +0200 Subject: [PATCH] update zeitgeist and add option to install local or remote releases Signed-off-by: cpanato --- .github/workflows/test-setup-zeitgeist.yml | 38 +++++++++++++++++++--- setup-zeitgeist/README.md | 1 + setup-zeitgeist/action.yml | 27 ++++++++++----- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-setup-zeitgeist.yml b/.github/workflows/test-setup-zeitgeist.yml index 0fb9bca..04e1960 100644 --- a/.github/workflows/test-setup-zeitgeist.yml +++ b/.github/workflows/test-setup-zeitgeist.yml @@ -51,7 +51,7 @@ jobs: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Install zeitgeist uses: ./setup-zeitgeist - - name: Check install! + - name: Check version run: zeitgeist version - name: Check root directory run: | @@ -72,8 +72,8 @@ jobs: matrix: os: [macos-latest, ubuntu-latest, windows-latest] go_version: - - '1.20' - '1.21' + - '1.22' name: Try to install zeitgeist with go ${{ matrix.go_version }} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 @@ -85,7 +85,8 @@ jobs: uses: ./setup-zeitgeist with: zeitgeist-release: 'main' - - name: Check install! + remote-version: 'false' + - name: Check version! run: zeitgeist version test_zeitgeist_action_custom_dir_root: @@ -104,7 +105,7 @@ jobs: with: install-dir: /usr/bin use-sudo: true - - name: Check install! + - name: Check version run: zeitgeist version - name: Check install dir! run: | @@ -130,7 +131,7 @@ jobs: uses: ./setup-zeitgeist with: install-dir: "$HOME/.zeitgeisttest" - - name: Check install! + - name: Check version run: zeitgeist version - name: Check install dir! run: | @@ -141,6 +142,33 @@ jobs: [[ -z $(git diff --stat) ]] shell: bash + test_zeitgeist_local: + needs: changes + if: ${{ needs.changes.outputs.zeitgeist == 'true' }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + permissions: {} + name: Install zeitgeist local + steps: + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - name: Install zeitgeist + uses: ./setup-zeitgeist + with: + remote-version: 'false' + - name: Check version + run: zeitgeist version + - name: Check root directory + run: | + if [[ $(git diff --stat) != '' ]]; then + echo 'should be clean' + exit 1 + else + exit 0 + fi + shell: bash + test_zeitgeist_action_wrong: runs-on: ${{ matrix.os }} needs: changes diff --git a/setup-zeitgeist/README.md b/setup-zeitgeist/README.md index 2d6032d..fe94631 100644 --- a/setup-zeitgeist/README.md +++ b/setup-zeitgeist/README.md @@ -84,5 +84,6 @@ The following optional inputs: | Input | Description | | --- | --- | | `zeitgeist-release` | `zeitgeist` version to use instead of the default. | +| `remote-version` | install `zeitgeist` that can check depencies from upstream repositories/registries. If false will install the local version only that only check local dependencies. | | `install-dir` | directory to place the `zeitgeist` binary into instead of the default (`$HOME/.zeitgeist`). | | `use-sudo` | set to `true` if `install-dir` location requires sudo privs. Defaults to false. | diff --git a/setup-zeitgeist/action.yml b/setup-zeitgeist/action.yml index 98e774e..95f764a 100644 --- a/setup-zeitgeist/action.yml +++ b/setup-zeitgeist/action.yml @@ -23,7 +23,11 @@ inputs: zeitgeist-release: description: 'zeitgeist release version to be installed' required: false - default: '0.4.3' + default: '0.5.3' + remote-version: + description: 'install zeitgeist that can check depencies from upstream repositories/registries. If false will install the local version only that only check local dependencies' + required: false + default: 'true' install-dir: description: 'Where to install the zeitgeist binary' required: false @@ -41,7 +45,7 @@ runs: use-sudo: ${{ inputs.use-sudo }} - shell: bash run: | - #!/bin/bash + #!/usr/bin/env bash # zeitgeist install script shopt -s expand_aliases if [ -z "$NO_COLOR" ]; then @@ -55,7 +59,12 @@ runs: mkdir -p ${{ inputs.install-dir }} - if [[ ${{ inputs.zeitgeist-release }} == "main" ]]; then + export ZEITGIEST_REMOTE= + if [[ ${{ inputs.remote-version }} == "true" ]]; then + export ZEITGIEST_REMOTE=-remote + fi + + if [[ ${{ inputs.zeitgeist-release }} == "main" && ${{ inputs.remote-version }} == "false" ]]; then log_info "installing zeitgeist via 'go install' from its main version" GOBIN=$(go env GOPATH)/bin go install sigs.k8s.io/zeitgeist@master @@ -71,15 +80,15 @@ runs: Linux) case ${{ runner.arch }} in X64) - desired_zeitgeist_filename='zeitgeist-amd64-linux' + desired_zeitgeist_filename="zeitgeist${ZEITGIEST_REMOTE}-amd64-linux" ;; ARM) - desired_zeitgeist_filename='zeitgeist-arm-linux' + desired_zeitgeist_filename="zeitgeist${ZEITGIEST_REMOTE}-arm-linux" ;; ARM64) - desired_zeitgeist_filename='zeitgeist-arm64-linux' + desired_zeitgeist_filename="zeitgeist${ZEITGIEST_REMOTE}-arm64-linux" ;; *) @@ -92,11 +101,11 @@ runs: macOS) case ${{ runner.arch }} in X64) - desired_zeitgeist_filename='zeitgeist-amd64-darwin' + desired_zeitgeist_filename="zeitgeist${ZEITGIEST_REMOTE}-amd64-darwin" ;; ARM64) - desired_zeitgeist_filename='zeitgeist-arm64-darwin' + desired_zeitgeist_filename="zeitgeist${ZEITGIEST_REMOTE}-arm64-darwin" ;; *) @@ -109,7 +118,7 @@ runs: Windows) case ${{ runner.arch }} in X64) - desired_zeitgeist_filename='zeitgeist-amd64-windows.exe' + desired_zeitgeist_filename="zeitgeist${ZEITGIEST_REMOTE}-amd64-windows.exe" zeitgeist_executable_name=zeitgeist.exe ;; *)