CI #14
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 | |
run-name: CI | |
on: | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
version: | |
description: The version to install | |
required: false | |
default: latest | |
type: string | |
channel: | |
description: The channel from which to install | |
required: false | |
default: stable | |
type: string | |
jobs: | |
set-matrix: | |
name: Set Testing Matrix | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ env.MATRIX }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "MATRIX=[ {\"version\": \"${{ inputs.version }}\", \"channel\": \"${{ inputs.channel }}\"} ]" >> $GITHUB_ENV | |
- uses: actions/setup-python@v5 | |
if: github.event_name != 'workflow_dispatch' | |
with: | |
python-version: '3.11' # for better datetime.fromisoformat() support | |
- id: set-matrix | |
if: github.event_name != 'workflow_dispatch' | |
run: echo "MATRIX=$( python ./.github/scripts/set-matrix.py )" >> $GITHUB_ENV | |
- name: echo matrix | |
run: jq <<< '${{ env.MATRIX }}' | |
test-action: | |
name: Test Setup Crossplane CLI | |
runs-on: ubuntu-latest | |
needs: set-matrix | |
strategy: | |
fail-fast: false | |
matrix: | |
inputs: ${{ fromJSON(needs.set-matrix.outputs.matrix) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: setup-crossplane-cli-default | |
uses: ./ | |
- name: setup-crossplane-cli-not-stable | |
uses: ./ | |
with: | |
channel: master | |
- name: setup-crossplane-cli | |
uses: ./ | |
with: | |
channel: ${{ matrix.inputs.channel }} | |
version: ${{ matrix.inputs.version }} | |
- name: Validate version | |
# versions pulled from channels other than "stable" may not have a --version flag | |
if: matrix.inputs.version != 'latest' && matrix.inputs.channel == 'stable' | |
run: | | |
crossplane version --client &> /dev/null | |
code=$? | |
if [[ "$code" -eq 0 ]]; then | |
[[ "$(crossplane version --client)" =~ *"${{ matrix.inputs.version }}"* ]] || exit 1 | |
else | |
[[ "$(crossplane --version)" =~ *"${{ matrix.inputs.version }}"* ]] || exit 1 | |
fi | |
ci-status: | |
name: CI Status | |
runs-on: ubuntu-latest | |
needs: test-action | |
if: always() | |
steps: | |
- name: CI Success | |
if: ${{ !(contains(needs.*.result, 'failure')) }} | |
run: exit 0 | |
- name: CI Failure | |
if: ${{ contains(needs.*.result, 'failure') }} | |
run: exit 1 |