Test new juju candidates #332
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: Test new juju candidates | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Run at 12AM UTC, every day | |
# Testing only needs permissions to read the repository contents. | |
permissions: | |
contents: read | |
jobs: | |
# Ensure project builds before running testing matrix | |
test-candidates: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
strategy: | |
fail-fast: false | |
max-parallel: 4 | |
matrix: | |
juju_track: | |
- "2.9" | |
juju_risk: | |
# - "candidate" | |
- "edge" | |
terraform: | |
- "1.5.*" | |
- "1.6.*" | |
steps: | |
- name: Set channel and artifact id | |
run: | | |
channel=$(echo ${{ matrix.juju_track }}/${{ matrix.juju_risk }}) | |
echo "Target channel is $channel" | |
echo "channel=$channel" >> $GITHUB_ENV | |
terraform_version=$(echo ${{ matrix.terraform }} | awk -F'\.' '{print $1$2}') | |
id=$(echo ${{ github.sha }}-${{ matrix.juju_track }}-${{ matrix.juju_risk }}-$terraform_version) | |
echo "Target id is $id" | |
echo "id=$id" >> $GITHUB_ENV | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.juju_track }} | |
- name: Download artifact | |
uses: dawidd6/action-download-artifact@v2 | |
id: download_artifact | |
with: | |
name: ${{ env.id }} | |
if_no_artifact_found: ignore | |
workflow_conclusion: success | |
- name: Check latest juju version tested | |
shell: bash | |
run: | | |
candidate=$(snap info juju | grep ${{ env.channel }} | awk '{print $2}') | |
last_tested=NA | |
if [ -f ${{ env.id }} ]; then | |
last_tested=$(cat ${{ env.id }}) | |
fi | |
echo "Last tested was $last_tested" | |
echo "Latest juju version found is $candidate" | |
next_test=NA | |
if [[ "$candidate" == "^" ]]; then | |
echo "No candidate to test" | |
else | |
if [[ "$candidate" == "$last_tested" ]]; then | |
echo "Candidate $candidate was already tested" | |
else | |
echo "Candidate $candidate has to be tested" | |
next_test="$candidate" | |
fi | |
fi | |
echo "next-test=$next_test" >> $GITHUB_ENV | |
echo "$next_test" > ~/${{ env.id }} | |
- name: Setup go | |
if: ${{ env.next-test != 'NA' }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- name: Install terraform | |
if: ${{ env.next-test != 'NA' }} | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ matrix.terraform }} | |
terraform_wrapper: false | |
- name: Install target juju | |
if: ${{ env.next-test != 'NA' }} | |
uses: charmed-kubernetes/actions-operator@main | |
with: | |
provider: ${{ matrix.cloud }} | |
juju-channel: ${{ env.channel }} | |
- name: "Set environment to configure provider" | |
if: ${{ env.next-test != 'NA' }} | |
# language=bash | |
run: | | |
CONTROLLER=$(juju whoami --format yaml | yq .controller) | |
echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV | |
echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV | |
echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV | |
echo "JUJU_CA_CERT<<EOF" >> $GITHUB_ENV | |
juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Run integration tests | |
if: ${{ env.next-test != 'NA' }} | |
id: test | |
env: | |
TF_ACC: "1" | |
TEST_CLOUD: ${{ matrix.cloud }} | |
run: go test -timeout 40m -v -cover ./internal/provider/ | |
timeout-minutes: 40 | |
- uses: actions/upload-artifact@v3 | |
if: ${{ success() }} | |
with: | |
name: ${{ env.id }} | |
path: "~/${{ env.id }}" |