From 4ebc00acc569c228c88ed4b14bf804dcab3eb969 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Thu, 8 Aug 2024 13:03:00 +0200 Subject: [PATCH] feat: Add GitHub Actions workflow and action for Vespa CLI Adds a GitHub Actions workflow to test the Vespa CLI installation using the latest and a specific version of the CLI. Also adds a reusable action to install the Vespa CLI on the runner. --- .github/workflows/test.yml | 39 ++++++++++++++++++++++++++++++++++ .yamllint | 7 +++++++ action.yml | 43 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 .yamllint create mode 100644 action.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e5b561d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +--- +name: Test + +on: + push: + branches: + - 1.x + pull_request: + branches: + - 1.x + +jobs: + test: + strategy: + fail-fast: true + matrix: + vespa-cli-version: [latest, 8.371.16] + runner: [ubuntu-latest, macos-latest] + + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Vespa CLI + uses: ./ + with: + version: ${{ matrix.vespa-cli-version }} + + - name: Verify Vespa CLI + run: vespa version + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Lint YAML files + run: yamllint --format github . diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..f28a9f8 --- /dev/null +++ b/.yamllint @@ -0,0 +1,7 @@ +--- +extends: default + +rules: + line-length: disable + truthy: + check-keys: false diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..d3df878 --- /dev/null +++ b/action.yml @@ -0,0 +1,43 @@ +--- +name: "Setup Vespa CLI" +description: "Installs the Vespa CLI tool on the runner." + +inputs: + # The version of the Vespa CLI to install. + version: + description: "The version of the Vespa CLI to install." + default: "latest" + +runs: + using: "composite" + steps: + - name: Select CLI version + shell: bash + id: vespa-cli-version + run: | + if [ "${{ inputs.version }}" == "latest" ]; then + VESPA_CLI_VERSION=$(curl -fsSL https://api.github.com/repos/vespa-engine/vespa/releases/latest | jq -r '.tag_name' | sed 's/^v//') + else + VESPA_CLI_VERSION="${{ inputs.version }}" + fi + + echo "version=${VESPA_CLI_VERSION}" >> "$GITHUB_OUTPUT" + + - name: Install Vespa CLI + shell: bash + env: + VESPA_CLI_VERSION: ${{ steps.vespa-cli-version.outputs.version }} + OS: ${{ startswith(runner.os, 'macOS') && 'darwin' || 'linux' }} + ARCH: ${{ startswith(runner.arch, 'ARM') && 'arm64' || 'amd64' }} + run: | + ARCHIVE_NAME="$(echo "vespa-cli_${VESPA_CLI_VERSION}_${OS}_${ARCH}" | tr '[:upper:]' '[:lower:]')" + DOWNLOAD_URL="https://github.com/vespa-engine/vespa/releases/download/v${VESPA_CLI_VERSION}/${ARCHIVE_NAME}.tar.gz" + echo "Downloading: ${DOWNLOAD_URL}" + + curl -fsSL "${DOWNLOAD_URL}" | tar -zxf - -C /opt + + chmod +x /opt/${ARCHIVE_NAME}/bin/* + ln -sf /opt/${ARCHIVE_NAME}/bin/vespa /usr/local/bin/ + + # Verify the installation + vespa version