From 325f77cdf1ee46abd1c5d8057805b5f6c5583cef Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Wed, 16 Aug 2023 21:57:39 +0900 Subject: [PATCH 1/4] Copy pr 534 --- .coveragerc | 3 ++ .github/workflows/python-coverage.yml | 42 +++++++++++++++++++++++++++ .github/workflows/python-tests.yml | 8 +++-- .gitignore | 5 ++++ pyproject.toml | 12 ++++++++ 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .coveragerc create mode 100644 .github/workflows/python-coverage.yml diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..26e44f99 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[run] +concurrency = multiprocessing,thread +source = optuna_dashboard/ diff --git a/.github/workflows/python-coverage.yml b/.github/workflows/python-coverage.yml new file mode 100644 index 00000000..d1d5d849 --- /dev/null +++ b/.github/workflows/python-coverage.yml @@ -0,0 +1,42 @@ +me: python coverage + +on: + push: + branches: + - master + pull_request: {} + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + architecture: x64 + + - name: Install dependencies + run: | + python -m pip install --progress-bar off --upgrade pip setuptools + pip install --progress-bar off .[optional] + pip install --progress-bar off .[test] + pip install --progress-bar off "optuna>=3.0.0" + pip install --progress-bar off . + echo 'import coverage; coverage.process_startup()' > sitecustomize.py + - name: Tests + env: + PYTHONPATH: . # To invoke sitecutomize.py + COVERAGE_PROCESS_START: .coveragerc # https://coverage.readthedocs.io/en/6.4.1/subprocess.html + COVERAGE_COVERAGE: yes # https://github.com/nedbat/coveragepy/blob/65bf33fc03209ffb01bbbc0d900017614645ee7a/coverage/control.py#L255-L261 + run: | + coverage run --source=optuna_dashboard -m pytest python_tests + coverage combine + coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 612ddb59..26cb4b8b 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,4 +1,4 @@ -name: tests +me: tests on: pull_request: branches: @@ -45,7 +45,8 @@ jobs: # python_tests requires optuna>=3.0.0 since it imports FloatDistribution run: | python -m pip install --progress-bar off --upgrade pip setuptools - pip install streamlit boto3 moto[s3] pytest + pip install --progress-bar off .[optional] + pip install --progress-bar off .[test] pip install --progress-bar off "optuna>=3.0.0" pip install --progress-bar off . - run: pytest python_tests @@ -61,7 +62,8 @@ jobs: - name: Install dependencies run: | python -m pip install --progress-bar off --upgrade pip setuptools - pip install streamlit boto3 moto[s3] pytest + pip install --progress-bar off .[optional] + pip install --progress-bar off .[test] pip install --progress-bar off . python -m pip install --progress-bar off --upgrade git+https://github.com/optuna/optuna.git - run: pytest python_tests diff --git a/.gitignore b/.gitignore index dde468fc..d530dc27 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,11 @@ docs/_generated/ rustlib/target/ rustlib/pkg/ +# Test +.coverage +.coverage.* +coverage.xml + # Others .envrc .idea/ diff --git a/pyproject.toml b/pyproject.toml index d9c0082c..2b4913db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,18 @@ dependencies = [ ] dynamic = ["version"] +[project.optional-dependencies] +test = [ + "coverage", + "pytest", + "moto[s3]", +] + +optional = [ + "streamlit", + "boto3", +] + [project.optional-dependencies] docs = [ "boto3", From 7140888553acd4d6e765d06449d7750edb7c9ee2 Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Wed, 16 Aug 2023 22:47:26 +0900 Subject: [PATCH 2/4] Fix typo --- .github/workflows/python-coverage.yml | 2 +- .github/workflows/python-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-coverage.yml b/.github/workflows/python-coverage.yml index d1d5d849..a2e61bef 100644 --- a/.github/workflows/python-coverage.yml +++ b/.github/workflows/python-coverage.yml @@ -1,4 +1,4 @@ -me: python coverage +name: python coverage on: push: diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 26cb4b8b..8fee4e44 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,4 +1,4 @@ -me: tests +name: tests on: pull_request: branches: From 54d4b51de8c57d0eb88febc1a4c1fccdde76de68 Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Wed, 16 Aug 2023 22:54:32 +0900 Subject: [PATCH 3/4] Fix error --- pyproject.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2b4913db..0555f701 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,13 @@ dependencies = [ dynamic = ["version"] [project.optional-dependencies] +docs = [ + "boto3", + "streamlit", + "sphinx", + "sphinx_rtd_theme", +] + test = [ "coverage", "pytest", @@ -45,13 +52,6 @@ optional = [ "boto3", ] -[project.optional-dependencies] -docs = [ - "boto3", - "streamlit", - "sphinx", - "sphinx_rtd_theme", -] [project.scripts] optuna-dashboard = "optuna_dashboard._cli:main" From 3aba421d63a731f6f0020a27192ecea3379a25c6 Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Wed, 30 Aug 2023 22:05:17 +0900 Subject: [PATCH 4/4] Add codecov token --- .github/workflows/python-coverage.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python-coverage.yml b/.github/workflows/python-coverage.yml index a2e61bef..4bda6350 100644 --- a/.github/workflows/python-coverage.yml +++ b/.github/workflows/python-coverage.yml @@ -9,6 +9,10 @@ on: jobs: coverage: runs-on: ubuntu-latest + + # Not intended for forks. + if: github.repository == 'optuna/optuna-dashboard' + steps: - name: Checkout uses: actions/checkout@v3 @@ -39,4 +43,6 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml + fail_ci_if_error: true