From 76a984a355837f4fea0a6083e7e25459b411f1a3 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Wed, 7 Aug 2024 14:37:11 +0200 Subject: [PATCH] feat: Add workflow to verify guides This change adds a new GitHub Actions workflow to verify the guides in the repository. The workflow checks out the code, installs the required dependencies (including the Vespa CLI), builds the Jekyll site, and runs a set of tests to ensure the guides are working as expected. The workflow is triggered on pull requests and pushes to a temporary branch, to allow for testing the configuration before merging to the main branch. --- .github/actions/install-deps/action.yml | 46 ++++++++++++++++++++++++ .github/workflows/verify-guides.yml | 47 +++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 .github/actions/install-deps/action.yml create mode 100644 .github/workflows/verify-guides.yml diff --git a/.github/actions/install-deps/action.yml b/.github/actions/install-deps/action.yml new file mode 100644 index 0000000000..ac3ac79b50 --- /dev/null +++ b/.github/actions/install-deps/action.yml @@ -0,0 +1,46 @@ +name: "Setup Vespa CLI and dependencies" +description: "Install Vespa CLI and dependencies" + +inputs: + # The version of the Vespa CLI to install. + vespa-cli-version: + description: "The version of the Vespa CLI to install." + required: true + default: "latest" + +runs: + using: "composite" + steps: + - name: Select CLI version + shell: bash + id: vespa-cli-version + run: | + if [ "${{ inputs.vespa-cli-version }}" == "latest" ]; then + VESPA_CLI_VERSION=$(curl -fsSL https://api.github.com/repos/vespa-engine/vespa/releases/latest | grep -Po '"tag_name": "v\K.*?(?=")') + else + VESPA_CLI_VERSION="${{ inputs.vespa-cli-version }}" + fi + + echo "version=${VESPA_CLI_VERSION}" >> "$GITHUB_OUTPUT" + + - name: Install dnf dependencies + shell: bash + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -qqq -r test/requirements.txt --user + python3 -m pip install -qqq pytest nbmake --user + + - name: Install python dependencies + shell: bash + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -qqq -r test/requirements.txt --user + python3 -m pip install -qqq pytest nbmake --user + + - name: Install Vespa CLI + shell: bash + env: + VESPA_CLI_VERSION: ${{ steps.vespa-cli-version.outputs.version }} + run: | + curl -fsSL https://github.com/vespa-engine/vespa/releases/download/v${VESPA_CLI_VERSION}/vespa-cli_${VESPA_CLI_VERSION}_linux_amd64.tar.gz | tar -zxf - -C /opt && \ + ln -sf /opt/vespa-cli_${VESPA_CLI_VERSION}_linux_amd64/bin/vespa /usr/local/bin/ diff --git a/.github/workflows/verify-guides.yml b/.github/workflows/verify-guides.yml new file mode 100644 index 0000000000..bc7d7f43d1 --- /dev/null +++ b/.github/workflows/verify-guides.yml @@ -0,0 +1,47 @@ +name: Verify Giudes + +on: + workflow_dispatch: # Allow manual triggering of this workflow. + + # START Temporary for testing. + pull_request: + branches: [main] + push: + branches: ["verify-guides-workflow-configuration"] + # END Temporary for testing. + +defaults: + run: + # Specify to ensure "pipefail and errexit" are set. + # Ref: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#defaultsrunshell + shell: bash + +jobs: + small: + runs-on: ubuntu-latest + container: + image: vespaengine/vespa-build-almalinux-8:latest + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/install-deps + with: + vespa-cli-version: latest + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + bundler-cache: true + + - name: build-site + run: | + bundle exec jekyll build + + - name: check-queries + run: | + ./test/test_queries.py _site + + - name: run-tests + run: | + ./test/test.py -c ./test/_test_config.yml -w $GITHUB_WORKSPACE