-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Propose CI infrastructures in github action #1494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
97f7aab
Use tox configuration
42e1e29
Add init.py to resolve pytest filename collision
bc199f0
Create pr-gate.yml (a new Github worflow)
d1c5c33
tox run-able
8743cd2
Use tox to run CI
25f4c6d
Add flake8 env
68a1ee9
Add spark build
18ca14a
Add report merging step
4ed9109
Fix pipeline
0d9e45a
Add flake8 and ascii flow chart
a71a999
Modify ascii flow chart
44a3c43
Add newline at EOF
5da9d3c
Install pytest-cov extension
b55d17e
Enable flake8 checks (unblocking)
f38d7e0
Fix typo
d385b2f
Try local github action
d27cdd6
Fix typos
50d87e5
Add merge-cov action
f040b0f
Rename job step
f743734
Disable source deletion
d1818d5
Use configurations from tox.ini
d74d7e1
Undo changes and remove pytest pins
d74eb4e
Undo source code deletion
7e46898
Remove html cov
d3d15a9
Add codecov config
7b346bd
Fix pipeline step
57880e2
Try modifying codecov
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| # --------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # --------------------------------------------------------- | ||
| name: pr-gate | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ laserprec/ghaction-ci ] | ||
|
|
||
| # This file defines following CI workflow: | ||
| # | ||
| # ┌──────────┐ ┌─────────┐ ┌────────┐ | ||
| # │ static ├─┬─► build* ├─┬─► test │ | ||
| # │ analysis │ │ │ (cpu) │ │ │ report │ | ||
| # └──────────┘ │ └─────────┘ │ └────────┘ | ||
| # │ ┌─────────┐ │ | ||
| # ├─► build* ├─┤ | ||
| # │ │ (spark) │ │ | ||
| # │ └─────────┘ │ | ||
| # │ ┌─────────┐ │ | ||
| # └─► build* ├─┘ | ||
| # │ (gpu) │ <-- TODO: Coming Soon | ||
| # └─────────┘ | ||
| # .... | ||
| # *each runs in PARALLEL different combinations | ||
| # of python version, OS, test subsets, etc | ||
| # | ||
| # ASCII chart created via https://asciiflow.com/ | ||
|
|
||
| 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 blocks (turned off to get a draft of the pipeline infrastracture) | ||
| 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 kind of tests are located in tests/<unit|integration|smoke> 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', 'not gpu and notebooks 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: Install build dependencies (tox) | ||
| run: | | ||
| python -m pip install --upgrade pip setuptools wheel | ||
| pip install tox | ||
|
|
||
| - name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}') | ||
| # '-e py' will use the default 'python' executable found in system path | ||
| # for why using tox, see: https://tox.readthedocs.io/en/latest/index.html | ||
| # tox will do: | ||
| # 1. build and install source distribution (sdist) | ||
| # 2. run static analysis on the code (not implemented yet) | ||
| # 3. run all of the specified test environment (i.e. run tests in different pyversions, etc) | ||
laserprec marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # 4. show test reports | ||
| run: | | ||
| tox -e py -- tests/${{ matrix.test-kind }} -m '${{ matrix.test-marker }}' | ||
|
|
||
| - name: Prepare Code Coverage Report | ||
| run: | | ||
| mv .coverage '.coverage_${{ matrix.test-marker }}_${{ matrix.test-kind }}_${{ matrix.os }}_${{ matrix.python }}' | ||
| ls .coverage* | ||
|
|
||
| - 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] | ||
| spark: [2.4.8] | ||
gramhagen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| hadoop: [2.6] | ||
| python: [3.6] | ||
| # different kind of tests are located in tests/<unit|integration|smoke> 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'] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| ################# Install spark dependencies (java, spark & hadoop) ################# | ||
| - name: Setup Java JDK | ||
| uses: actions/setup-java@v2.1.0 | ||
| with: | ||
| java-version: ${{ matrix.java }} | ||
| distribution: 'adopt' | ||
|
|
||
| - name: Setup Apache Spark | ||
laserprec marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| uses: vemonet/setup-spark@v1 | ||
| with: | ||
| # Apache Spark version to install, see https://spark.apache.org/downloads.html | ||
| spark-version: ${{ matrix.spark }} | ||
| # Hadoop version | ||
| hadoop-version: ${{ matrix.hadoop }} | ||
|
|
||
| ################# Run Python tests ################# | ||
laserprec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Use Python ${{ matrix.python }} | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
|
|
||
| - name: Install build dependencies (tox) | ||
| run: | | ||
| python -m pip install --upgrade pip setuptools wheel | ||
| pip install tox | ||
|
|
||
| - name: Run ${{ matrix.test-kind }} tests ('${{ matrix.test-marker }}') | ||
| run: | | ||
| tox -e py -- tests/${{ matrix.test-kind }} -m '${{ matrix.test-marker }}' | ||
|
|
||
| - name: Prepare Code Coverage Report | ||
| run: | | ||
| mv .coverage '.coverage_${{ matrix.test-marker }}_${{ matrix.test-kind }}_${{ matrix.os }}_${{ matrix.python }}' | ||
| ls .coverage* | ||
|
|
||
| - 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] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v2.2.2 | ||
| with: | ||
| python-version: '3.6' | ||
|
|
||
| - name: Install dev-dependencies | ||
| run: | | ||
| pip install --upgrade pip setuptools wheel | ||
| python -m pip install coverage | ||
|
|
||
| - name: Download coverage reports from all previous jobs | ||
| uses: actions/download-artifact@v2 | ||
| with: | ||
| name: code-cov | ||
|
|
||
| - name: Show downloaded coverage reports | ||
| run: ls .coverage* | ||
|
|
||
| # Merge code coverge reports so the coverage numbers are accurate across | ||
| # different runsof subsets of tests | ||
| - name: Merage coverage reports | ||
laserprec marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run: | | ||
| python -m coverage combine .coverage* | ||
| python -m coverage report | ||
| python -m coverage xml | ||
|
|
||
| - name: Show merged report | ||
| run: | | ||
| ls *.xml | ||
|
|
||
| - name: Upload code coverage report to CodeCov | ||
| uses: codecov/codecov-action@v2.0.2 | ||
| with: | ||
| fail_ci_if_error: true | ||
| files: ./coverage.xml | ||
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
This file was deleted.
Oops, something went wrong.
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
Empty file.
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
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| [tox] | ||
| # py will use whatever the basepython `python` maps to from PATH | ||
| # you can use py38, for example, to chosse a different version | ||
| # See https://tox.readthedocs.io/en/latest/config.html#tox-environments | ||
| envlist = py | ||
|
|
||
|
|
||
| [testenv] | ||
| # Reading additional dependencies to run the test | ||
| # https://tox.readthedocs.io/en/latest/example/basic.html#depending-on-requirements-txt-or-defining-constraints | ||
| ; deps = -rrequirements-dev.txt | ||
| # similar to 'pip install recommenders-*.whl[test]' | ||
| extras = all | ||
| commands = | ||
| # {posargs} will be substituded by arguments after the `--` when running. | ||
| # This will allow running subset of the test suite via tox. | ||
| # | ||
| # EX: tox -- -m "not spark and not gpu" | ||
| # will pass {-m "not spark and not gpu"} to `pytest` | ||
| # See https://tox.readthedocs.io/en/latest/example/general.html for more details | ||
| pytest {posargs} | ||
|
|
||
|
|
||
| [testenv:flake8] | ||
| deps = flake8 | ||
| skip_install = True | ||
| commands = flake8 . | ||
|
|
||
|
|
||
| # Configurations for running pytest | ||
| [pytest] | ||
| log_cli = False | ||
| log_format = %(asctime)s %(levelname)s %(message)s | ||
| junit_family = xunit2 | ||
| # This enable custom marker as decorator "@pytest.mark.gpu" | ||
| markers = | ||
| # markers allow to us to run faster subset of the test: | ||
| # EX: pytest -m "not spark and not gpu" | ||
| # See https://docs.pytest.org/en/stable/example/markers.html#registering-markers | ||
| deeprec: test deeprec model | ||
| sequential: test sequential model | ||
| notebooks: mark a test as notebooks test | ||
| smoke: mark a test as smoke test | ||
| integration: mark a test as integration test | ||
| gpu: mark a test as gpu test | ||
| spark: mark a test as spark test | ||
| vw: mark a test as vowpal wabbit test | ||
| testpaths = | ||
| tests | ||
| addopts = | ||
| # reports all (except passed tests). See https://docs.pytest.org/en/latest/usage.html#detailed-summary-report | ||
| -ra | ||
| --durations 0 | ||
| --cov-append --cov=recommenders --cov-report=html --cov-report=term-missing --cov-report=xml --junitxml=junit/test-results.xml | ||
|
|
||
|
|
||
| [flake8] | ||
| ; # Configs for flake8-import-order, see https://pypi.org/project/flake8-import-order/ for more info. | ||
| ; import-order-style=edited | ||
| ; application-import-names=recommenders, tests | ||
| # Native flake8 configs | ||
| max-line-length = 140 | ||
| exclude = | ||
| build, dist, docs, examples, | ||
| tests | ||
| .env*,.venv* # local virtual environments | ||
| .tox | ||
laserprec marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.