Update the toolctl API #1093
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
detect-updated-tools: | |
runs-on: ubuntu-latest | |
outputs: | |
any_updated: ${{steps.updated-tools.outputs.any_updated}} | |
tools: ${{steps.updated-tools.outputs.tools}} | |
env: | |
TOOL_GLOB: v0/*/** | |
TOOL_REGEX: v0/([^/]+)/ | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 | |
with: | |
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | |
- name: Check out the API | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Detect all changed files | |
id: changed-files | |
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6 | |
with: | |
files: | | |
${{env.TOOL_GLOB}} | |
- name: Detect all updated tools | |
id: updated-tools | |
if: ${{steps.changed-files.outputs.any_changed == 'true'}} | |
run: | | |
# Check if we're running Bash 4 or higher | |
if [ -z "$BASH_VERSION" ] || [ "${BASH_VERSION:0:1}" -lt "4" ]; then | |
echo "Bash 4 or higher is required." | |
exit 1 | |
fi | |
# Extract the names of all updated tools | |
declare -A tools | |
for path in ${{steps.changed-files.outputs.all_changed_files}}; do | |
if [[ $path =~ ${{env.TOOL_REGEX}} ]]; then | |
tools["${BASH_REMATCH[1]}"]="" | |
else | |
echo "$path doesn't match" >&2 | |
fi | |
done | |
# Set the GitHub Actions output | |
echo "any_updated=true" >> $GITHUB_OUTPUT | |
echo "tools=${!tools[@]}" >> $GITHUB_OUTPUT | |
install-test: | |
needs: [detect-updated-tools] | |
if: ${{needs.detect-updated-tools.outputs.any_updated == 'true'}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
runs-on: ${{matrix.os}} | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 | |
with: | |
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | |
- name: Add ~/.local/bin to the PATH | |
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Install toolctl | |
run: curl -fsSL https://raw.githubusercontent.com/toolctl/install/main/install | sh | |
- name: Set the LocalAPIBasePath | |
env: | |
TOOLCTL_API_VERSION: v0 | |
run: | | |
config_dir="$HOME/.config/toolctl" | |
mkdir -p "${config_dir}" | |
echo LocalAPIBasePath: "${GITHUB_WORKSPACE}/${TOOLCTL_API_VERSION}" > "${config_dir}/config.yaml" | |
- name: Check out the repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Install the latest version of each tool | |
run: toolctl install ${{needs.detect-updated-tools.outputs.tools}} --local | |
- name: Test the discover mechanism for each tool on Linux | |
if: runner.os == 'Linux' | |
run: toolctl api discover ${{needs.detect-updated-tools.outputs.tools}} --os linux | |
- name: Test the discover mechanism for each tool on macOS | |
if: runner.os == 'macOS' | |
run: toolctl api discover ${{needs.detect-updated-tools.outputs.tools}} --os darwin |