Long CI #477
This file contains hidden or 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
| # Copyright 2023 The Nuclio Authors. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| name: Long CI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 'PR number' | |
| required: false | |
| default: '' | |
| schedule: | |
| - cron: '0 */12 * * *' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| START_LABEL: long-ci-started | |
| SUCCESS_LABEL: long-ci-succeeded | |
| CANCEL_LABEL: long-ci-cancelled | |
| FAILURE_LABEL: long-ci-failed | |
| ADD_REMOVE_LABELS_SCRIPT_PATH: hack/scripts/ci/add-remove-labels.js | |
| DOCKER_BUILDKIT: 1 | |
| jobs: | |
| set_start_label: | |
| name: Set Start Label | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.pr_number != '' && github.repository == 'nuclio/nuclio' | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - name: Set 'long-ci-started' Label | |
| uses: actions/github-script@v8 | |
| env: | |
| PR_NUMBER: ${{ github.event.inputs.pr_number }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const prNumber = process.env.PR_NUMBER; | |
| const labelsToAdd = [process.env.START_LABEL]; | |
| const labelsToRemove = [process.env.SUCCESS_LABEL, process.env.CANCEL_LABEL, process.env.FAILURE_LABEL]; | |
| const script = require(`${process.env.GITHUB_WORKSPACE}/${process.env.ADD_REMOVE_LABELS_SCRIPT_PATH}`); | |
| await script({ github, context, prNumber, labelsToAdd, labelsToRemove }); | |
| long_ci: | |
| name: Long CI | |
| runs-on: ubuntu-latest | |
| if: ( github.repository == 'nuclio/nuclio' && github.event_name != 'workflow_dispatch' ) || github.event_name == 'workflow_dispatch' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| command: [ nuctl-tests,dotnet-tests,golang-tests,java-tests,python-tests,python-runtime-tests,fast-tests, kafka-tests ] | |
| steps: | |
| # checkout from development | |
| - uses: actions/checkout@v6 | |
| if: github.event.inputs.pr_number == '' | |
| - if : ${{ github.event.inputs.pr_number != '' }} | |
| name: Running on specific PR | |
| run: echo "PR number - ${{ github.event.inputs.pr_number }}" | |
| # checkout from PR | |
| - uses: actions/checkout@v6 | |
| if: github.event.inputs.pr_number != '' | |
| with: | |
| fetch-depth: 0 | |
| ref: refs/pull/${{ github.event.inputs.pr_number }}/merge | |
| - name: Freeing up disk space | |
| run: "${GITHUB_WORKSPACE}/hack/scripts/ci/free-space.sh" | |
| - uses: actions/setup-go@v6 | |
| with: | |
| cache: true | |
| go-version-file: go.mod | |
| - name: Build | |
| run: make build | |
| env: | |
| NUCLIO_NUCTL_CREATE_SYMLINK: false | |
| - name: Test (Scheduled) | |
| if: github.event_name == 'schedule' | |
| run: LIST_TESTS_MAKE_COMMAND=${{ matrix.command }} make test | |
| env: | |
| NUCLIO_CI_SKIP_STRESS_TEST: true | |
| - name: Test (Non-Scheduled) | |
| if: github.event_name != 'schedule' | |
| run: LIST_TESTS_MAKE_COMMAND=${{ matrix.command }} make test | |
| - name: System stats on failure | |
| if: ${{ failure() }} | |
| run: "${GITHUB_WORKSPACE}/hack/scripts/ci/system-stats.sh" | |
| long_ci_results: | |
| name: Analyze Long CI Results | |
| runs-on: ubuntu-latest | |
| needs: long_ci | |
| if: always() | |
| steps: | |
| - name: Determine Final Status | |
| id: determine_status | |
| run: | | |
| if [ "${{ needs.long_ci.result }}" == "success" ]; then | |
| echo "LONG_CI_FINISH_LABEL=${{ env.SUCCESS_LABEL }}" >> $GITHUB_ENV | |
| elif [ "${{ needs.long_ci.result }}" == "failure" ]; then | |
| echo "LONG_CI_FINISH_LABEL=${{ env.FAILURE_LABEL }}" >> $GITHUB_ENV | |
| elif [ "${{ needs.long_ci.result }}" == "cancelled" ]; then | |
| echo "LONG_CI_FINISH_LABEL=${{ env.CANCEL_LABEL }}" >> $GITHUB_ENV | |
| fi | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - name: Set labels | |
| if: github.event.inputs.pr_number != '' && github.repository == 'nuclio/nuclio' | |
| uses: actions/github-script@v8 | |
| env: | |
| PR_NUMBER: ${{ github.event.inputs.pr_number }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const prNumber = process.env.PR_NUMBER | |
| const labelsToAdd = [ process.env.LONG_CI_FINISH_LABEL ] | |
| const labelsToRemove = [ process.env.START_LABEL ] | |
| const script = require(`${ process.env.GITHUB_WORKSPACE }/${ process.env.ADD_REMOVE_LABELS_SCRIPT_PATH }`) | |
| await script({ github, context, prNumber, labelsToAdd, labelsToRemove }) | |
| - name: Report Status | |
| if: github.event_name == 'schedule' && always() | |
| uses: ravsamhq/notify-slack-action@be814b201e233b2dc673608aa46e5447c8ab13f2 # 2.5.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| status: ${{ needs.long_ci.result }} | |
| notify_when: "failure" | |
| notification_title: "{workflow} has failed" | |
| message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" | |
| footer: "<{repo_url}|{repo}> | <{run_url}|View Run>" | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |