From f06c5e44fd4f4c21cb9e3058de0d2484806f5084 Mon Sep 17 00:00:00 2001 From: Robert Gildein Date: Wed, 10 Apr 2024 12:14:29 +0200 Subject: [PATCH] test --- .github/workflows/weekly_tests.yaml | 227 ++++++++++++++++------------ 1 file changed, 129 insertions(+), 98 deletions(-) diff --git a/.github/workflows/weekly_tests.yaml b/.github/workflows/weekly_tests.yaml index 600689f..d4fd53b 100644 --- a/.github/workflows/weekly_tests.yaml +++ b/.github/workflows/weekly_tests.yaml @@ -10,79 +10,77 @@ jobs: name: Run weekly tests runs-on: ubuntu-latest timeout-minutes: 1440 - outputs: - failed_tests: ${{ steps.collect-failed-tests.outputs.failed_tests }} strategy: max-parallel: 3 fail-fast: false matrix: include: - - repo: charm-advanced-routing - workflow_file_name: check.yaml - branch: master - - repo: charm-apt-mirror - workflow_file_name: check.yaml - branch: main - - repo: charm-cloudsupport - workflow_file_name: check.yaml - branch: main - - repo: charm-duplicity - workflow_file_name: check.yaml - branch: master - - repo: hardware-observer-operator - workflow_file_name: check.yaml - branch: master - - repo: hardware-observer-operator - workflow_file_name: cos_integration.yaml - branch: master - - repo: charm-juju-backup-all - workflow_file_name: check.yaml - branch: master - - repo: charm-juju-local - workflow_file_name: check.yaml - branch: master - - repo: charm-kubernetes-service-checks - workflow_file_name: check.yaml - branch: master - - repo: charm-local-users - workflow_file_name: check.yaml - branch: main - - repo: charm-logrotated - workflow_file_name: check.yaml - branch: master - - repo: charm-nginx - workflow_file_name: check.yaml - branch: main - - repo: charm-openstack-service-checks - workflow_file_name: check.yaml - branch: master - - repo: charm-prometheus-blackbox-exporter - workflow_file_name: check.yaml - branch: master - - repo: charm-prometheus-libvirt-exporter - workflow_file_name: check.yaml - branch: master - - repo: charm-simple-streams - workflow_file_name: check.yaml - branch: main - - repo: charm-storage-connector - workflow_file_name: check.yaml - branch: master - - repo: charm-sysconfig - workflow_file_name: check.yaml - branch: master - - repo: charm-userdir-ldap - workflow_file_name: check.yaml - branch: master - - repo: prometheus-hardware-exporter - workflow_file_name: check.yaml - branch: main - - repo: prometheus-juju-exporter - workflow_file_name: pr.yaml - branch: main - - repo: prometheus-juju-backup-all-exporter - workflow_file_name: check.yaml - branch: main + # - repo: charm-advanced-routing + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-apt-mirror + # workflow_file_name: check.yaml + # branch: main + # - repo: charm-cloudsupport + # workflow_file_name: check.yaml + # branch: main + # - repo: charm-duplicity + # workflow_file_name: check.yaml + # branch: master + # - repo: hardware-observer-operator + # workflow_file_name: check.yaml + # branch: master + # - repo: hardware-observer-operator + # workflow_file_name: cos_integration.yaml + # branch: master + # - repo: charm-juju-backup-all + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-juju-local + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-kubernetes-service-checks + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-local-users + # workflow_file_name: check.yaml + # branch: main + # - repo: charm-logrotated + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-nginx + # workflow_file_name: check.yaml + # branch: main + # - repo: charm-openstack-service-checks + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-prometheus-blackbox-exporter + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-prometheus-libvirt-exporter + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-simple-streams + # workflow_file_name: check.yaml + # branch: main + # - repo: charm-storage-connector + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-sysconfig + # workflow_file_name: check.yaml + # branch: master + # - repo: charm-userdir-ldap + # workflow_file_name: check.yaml + # branch: master + # - repo: prometheus-hardware-exporter + # workflow_file_name: check.yaml + # branch: main + # - repo: prometheus-juju-exporter + # workflow_file_name: pr.yaml + # branch: main + # - repo: prometheus-juju-backup-all-exporter + # workflow_file_name: check.yaml + # branch: main - repo: snap-tempest workflow_file_name: pr.yaml branch: main @@ -91,42 +89,75 @@ jobs: branch: main steps: + # - name: Running ${{ matrix.workflow_file_name }} tests for ${{ matrix.repo }} + # uses: convictional/trigger-workflow-and-wait@v1.6.5 + # id: dispatched-tests + # with: + # owner: canonical + # repo: ${{ matrix.repo }} + # github_token: ${{ secrets.GHA_WORKFLOW_TRIGGER }} + # workflow_file_name: ${{ matrix.workflow_file_name }} + # ref: ${{ matrix.branch }} + # wait_interval: 60 + - name: Running ${{ matrix.workflow_file_name }} tests for ${{ matrix.repo }} - uses: convictional/trigger-workflow-and-wait@v1.6.5 id: dispatched-tests - with: - owner: canonical - repo: ${{ matrix.repo }} - github_token: ${{ secrets.GHA_WORKFLOW_TRIGGER }} - workflow_file_name: ${{ matrix.workflow_file_name }} - ref: ${{ matrix.branch }} - wait_interval: 60 - - - name: Collect failed tests - id: collect-failed-tests - env: - WORKFLOW_URL: ${{ steps.dispatched-tests.outputs.workflow_url }} - if: ${{ failure() }} run: | - failed_tests="" - if [ "${{ steps.dispatched-tests.outcome }}" != "success" ]; then - failed_tests+="[${{ matrix.repo }}]($WORKFLOW_URL), " + echo "workflow_url=https://test.org" >> "$GITHUB_OUTPUT" + if [ "${{ matrix.workflow_file_name }}" == "pr.yaml" ]; then + exit 1 # simulate failure + else + exit 0 # simulate passing fi - # Set the output variable to pass the failed tests to the next job - echo "failed_tests=$failed_tests" >> "$GITHUB_OUTPUT" - notify-on-failure: - needs: [weekly-tests] - if: ${{ failure() }} - name: Notify Mattermost Channel + - name: Collect result + id: collect-result + if: always() + run: | + result=$(cat <<-END + { + "job-index": "${{ strategy.job-index }}", + "repo": "${{ matrix.repo }}", + "branch": "${{ matrix.branch }}", + "workflow_file_name":"${{ matrix.workflow_file_name }}", + "conclusion": "${{ steps.dispatched-tests.outcome }}", + "workflow_url": "${{ steps.dispatched-tests.outputs.workflow_url }}" + } + END + ) + echo $result > "result-${{ strategy.job-index }}.json" + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: "result-${{ strategy.job-index }}.json" + path: "result-${{ strategy.job-index }}.json" + + notify: + needs: weekly-tests + if: always() # these needs to be run always + name: Notify SolEng with results runs-on: ubuntu-latest steps: - - name: Create the Mattermost Message - env: - WEEKLY_TESTS: ${{ needs.weekly-tests.outputs.failed_tests }} + - name: Collect results + uses: actions/download-artifact@v4 + - name: Install jq + run: | + sudo apt update + sudo apt install jq -y + - name: Create result message + id: message run: | - echo "{\"text\":\":robot_face: [Weekly tests]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) have failed for these projects: $WEEKLY_TESTS\"}" > mattermost.json + jq -s '.[] | ["- [\(.repo) (\(.branch), \(.workflow_file_name))](\(.workflow_url)) \(if .conclusion == "success" then ":gh-success-octicon-checkcirclefillicon:" else ":gh-failure-octicon-xcirclefillicon:" end)"] | join("\n")' result-0.json + # message=$(echo $merged_json | jq -r '.[] | ["- [\(.repo) (\(.branch), \(.workflow_file_name))](\(.workflow_url)) \(if .conclusion == "success" then ":gh-success-octicon-checkcirclefillicon:" else ":gh-failure-octicon-xcirclefillicon:" end)"] | join("\n")') + # echo $message + # echo "message=$message" >> "$GITHUB_OUTPUT" + # - name: Create the Mattermost Message + # env: + # WEEKLY_TESTS: ${{ needs.weekly-tests.outputs.failed_tests }} + # run: | + # echo "{\"text\":\":robot_face: [Weekly tests]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) have failed for these projects: $WEEKLY_TESTS\"}" > mattermost.json - - uses: mattermost/action-mattermost-notify@master - env: - MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} + # - uses: mattermost/action-mattermost-notify@master + # env: + # MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}