diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000000..15ef7ba159 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,240 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# --------------------------------------------------------- + +# NOTE: +# This file defines following CI workflow: +# ┌──────────┐ ┌─────────┐ ┌────────┐ +# │ static ├─┬─► build* ├─┬─► test │ +# │ analysis │ │ │ (cpu) │ │ │ report │ +# └──────────┘ │ └─────────┘ │ └────────┘ +# │ ┌─────────┐ │ +# ├─► build* ├─┤ +# │ │ (spark) │ │ +# │ └─────────┘ │ +# │ ┌─────────┐ │ +# └─► build* ├─┘ +# │ (gpu) │ +# └─────────┘ +# .... +# *each runs in PARALLEL the different combinations +# of python version, OS, test subsets, etc +# +# There are 3 compute environments our library is supporting: CPU, GPU and Spark +# This pipeline's goal is to ensure we run and pass our tests in these supported compute +# For all of the jobs in GPU build, we are using self-host VMs to run them. +# For the rest of the jobs, with the exception of integration tests (#1507), we will use default agents provided by GitHub +# +# ASCII chart created via https://asciiflow.com/ +name: nightly + +on: + # ┌───────────── minute (0 - 59) + # │ ┌───────────── hour (0 - 23) + # │ │ ┌───────────── day of the month (1 - 31) + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) + # │ │ │ │ │ + # │ │ │ │ │ + schedule: + - cron: '0 0 * * *' # basically running everyday at 12AM + # cron works with default branch (main) only: # https://github.community/t/on-schedule-per-branch/17525/2 + + push: + # because we can't schedule runs for non-main branches, + # to ensure we are running the build on the staging branch, we can add push policy for it + branches: [staging] + + # enable manual trigger + workflow_dispatch: + input: + tags: + description: 'Test scenario tags' + default: 'Anything to describe this manual run (optional)' + + +jobs: +############################################### +############### STATIC-ANALYSIS ############### +############################################### + static-analysis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + + - name: Install dependencies (tox) + run: | + python -m pip install --upgrade pip setuptools wheel + pip install tox + + - name: Run flake8 + # TODO: re-enable this flake8 block (turned off to get a draft of the pipeline infrastructure) + continue-on-error: true + run: | + tox -e flake8 + +############################################### +################## CPU-BUILD ################## +############################################### + build-cpu: + runs-on: ${{ matrix.os }} + needs: static-analysis + strategy: + matrix: + os: [ubuntu-latest] + python: [3.6] + # different kinds of tests are located in tests/ folders + test-kind: ['unit', 'smoke'] + # pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html + test-marker: ['not spark and not gpu'] + include: + # Integration tests need a powerful machine with more memory. GitHub-hosted agents only have 7GB memory. + # TODO: Optimization/refactoring should be done to ensure that these test can run in the default CI agent (#1507) + - os: self-hosted + python: 3.6 + test-kind: 'integration' + test-marker: 'not spark and not gpu' + + steps: + - uses: actions/checkout@v2 + ################# Run Python tests ################# + - name: Use Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + # There are little documentation on how to call **local** actions + # https://docs.github.com/en/actions/creating-actions/about-actions#choosing-a-location-for-your-action + # but there is some working insights from this discussion: + # https://github.community/t/path-to-action-in-the-same-repository-as-workflow/16952/2 + - name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}') + uses: ./.github/workflows/actions/run-tests + with: + test-kind: ${{ matrix.test-kind }} + test-marker: ${{ matrix.test-marker }} + # Currently GitHub workflow cannot call an action from another action + # https://github.community/t/call-an-action-from-another-action/17524 + # Else this shared step can also be move to the local action: .github/workflows/actions/run-tests + - name: Upload Code Coverage + uses: actions/upload-artifact@v2 + with: + name: code-cov + path: .coverage* + +############################################### +################# SPARK-BUILD ################# +############################################### + build-spark: + runs-on: ${{ matrix.os }} + needs: static-analysis + strategy: + matrix: + os: [ubuntu-latest] + java: [8] + python: [3.6] + # different kinds of tests are located in tests/ folders + test-kind: ['unit', 'smoke'] + # pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html + test-marker: ['spark and not gpu'] + include: + # Integration tests need a powerful machine with more memory. GitHub-hosted agents only have 7GB memory. + # TODO: Optimization/refactoring should be done to ensure that these test can run in the default CI agent (#1507) + - os: self-hosted + java: 8 + python: 3.6 + test-kind: 'integration' + test-marker: 'spark and not gpu' + + steps: + - uses: actions/checkout@v2 + ################# Install spark dependencies (java) ################# + - name: Setup Java JDK + uses: actions/setup-java@v2.1.0 + with: + java-version: ${{ matrix.java }} + distribution: 'adopt' + + ################# Run Python tests ################# + - name: Use Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + - name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}') + uses: ./.github/workflows/actions/run-tests + with: + test-kind: ${{ matrix.test-kind }} + test-marker: ${{ matrix.test-marker }} + + - name: Upload Code Coverage + uses: actions/upload-artifact@v2 + with: + name: code-cov + path: .coverage* + +############################################### +################# GPU-BUILD ################# +############################################### + build-gpu: + runs-on: [self-hosted, Linux, gpu] # this is a union of labels to select specific self-hosted machine + needs: static-analysis + strategy: + matrix: + python: [3.6] + # different kinds of tests are located in tests/ folders + test-kind: ['unit', 'smoke', 'integration'] + # pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html + test-marker: ['gpu and not spark'] + + steps: + - uses: actions/checkout@v2 + + ################# Run Python tests ################# + - name: Use Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + - name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}') + uses: ./.github/workflows/actions/run-tests + with: + test-kind: ${{ matrix.test-kind }} + test-marker: ${{ matrix.test-marker }} + + - name: Upload Code Coverage + uses: actions/upload-artifact@v2 + with: + name: code-cov + path: .coverage* + +############################################### +############ TEST COVERAGE SUMMARY ############ +############################################### + collect-code-cov: + runs-on: ubuntu-latest + needs: [build-cpu, build-spark, build-gpu] + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2.2.2 + with: + python-version: '3.6' + + - name: Download coverage reports from all previous jobs + uses: actions/download-artifact@v2 + with: + name: code-cov + + - name: Merge coverage reports + uses: ./.github/workflows/actions/merge-cov + + - name: Upload code coverage report to CodeCov + uses: codecov/codecov-action@v2.0.2 + with: + fail_ci_if_error: true + # comes from the last 'Merge coverage reports' step + files: ./coverage.xml diff --git a/.github/workflows/pr-gate.yml b/.github/workflows/pr-gate.yml index 953b31fc6f..5f0320ba7a 100644 --- a/.github/workflows/pr-gate.yml +++ b/.github/workflows/pr-gate.yml @@ -2,17 +2,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # --------------------------------------------------------- -name: pr-gate - -on: - pull_request: - branches: [ staging, main ] - # development triggers can be removed afterwards. - push: - branches: [ laserprec/gpu-ci, laserprec/ghaction-sandbox* ] +# NOTE: # This file defines following CI workflow: -# # ┌──────────┐ ┌─────────┐ ┌────────┐ # │ static ├─┬─► build* ├─┬─► test │ # │ analysis │ │ │ (cpu) │ │ │ report │ @@ -29,7 +21,24 @@ on: # *each runs in PARALLEL the different combinations # of python version, OS, test subsets, etc # -# ASCII chart created via https://asciiflow.com/ +# There are 3 compute environments our library is supporting: CPU, GPU and Spark +# This pipeline's goal is to ensure we run and pass our tests in these supported compute envs +# For all of the jobs in GPU build, we are using self-host VMs to run them. +# +# ASCII chart created via https://asciiflow.com/ +name: pr-gate + +on: + pull_request: + branches: [ staging, main ] + + # enable manual trigger + workflow_dispatch: + input: + tags: + description: 'Test scenario tags' + default: 'Anything to describe this manual run (optional)' + jobs: ############################################### @@ -65,7 +74,7 @@ jobs: matrix: os: [ubuntu-latest] python: [3.6] - # different kind of tests are located in tests/ folders + # different kinds of tests are located in tests/ folders test-kind: ['unit'] # pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html test-marker: ['not gpu and not spark and not notebooks', 'notebooks and not gpu and not spark'] @@ -106,7 +115,7 @@ jobs: os: [ubuntu-latest] java: [8] python: [3.6] - # different kind of tests are located in tests/ folders + # different kinds of tests are located in tests/ folders test-kind: ['unit'] # pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html test-marker: ['notebooks and spark and not gpu', 'spark and not notebooks and not gpu'] @@ -147,7 +156,7 @@ jobs: strategy: matrix: python: [3.6] - # different kind of tests are located in tests/ folders + # different kinds of tests are located in tests/ folders test-kind: ['unit'] # pytest markers configured in tox.ini. See https://docs.pytest.org/en/6.2.x/example/markers.html test-marker: ['gpu and notebooks and not spark', 'gpu and not notebooks and not spark']