From 67a03d9d7c949d7c23ed05b060d90714da7a1360 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Tue, 20 Aug 2024 00:18:56 -0400 Subject: [PATCH 1/3] Apply the new workflow --- .github/workflows/codecov.yml | 62 +++++++++++++++++++++++++++++++ .github/workflows/docs.yml | 48 +++++++++++++----------- .github/workflows/main.yml | 64 -------------------------------- .github/workflows/pre-commit.yml | 19 ---------- .github/workflows/test.yml | 52 ++++++++++++++++++++++++++ README.rst | 4 +- 6 files changed, 143 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/codecov.yml delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/pre-commit.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 00000000..465d42c7 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,62 @@ +name: Gather coverage report and upload to codecov + +on: + push: + branches: + - main + release: + types: + - prereleased + - published + workflow_dispatch: + +defaults: + run: + shell: bash -l {0} + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Check out diffpy.pdfgui + uses: actions/checkout@v4 + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + auto-update-conda: true + environment-file: environment.yml + auto-activate-base: false + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install diffpy.pdfgui and requirements + run: | + conda install --file requirements/run.txt + conda install --file requirements/test.txt + python -m pip install -r requirements/pip.txt + python -m pip install . --no-deps + + - name: Install Xvfb + run: sudo apt-get install -y xvfb + + - name: Start Xvfb + run: | + export DISPLAY=:99 + Xvfb :99 -screen 0 1024x768x16 & + + - name: Validate diffpy.pdfgui + run: | + export DISPLAY=:99 + coverage run -m pytest -vv -s + coverage report -m + codecov + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2909d67f..e0fca501 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,37 +1,43 @@ -name: Build Documentation +name: Build and Deploy Documentation on: - push: - branches: - - main release: + types: + - prereleased + - published + workflow_dispatch: + +defaults: + run: + shell: bash -l {0} jobs: - test: + docs: runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: Check out diffpy.pdfgui + uses: actions/checkout@v4 - - uses: conda-incubator/setup-miniconda@v2 + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 with: activate-environment: build auto-update-conda: true + environment-file: environment.yml + auto-activate-base: false - - name: install requirements + - name: Conda config run: >- - conda install -n build -c conda-forge - --file requirements/build.txt - --file requirements/run.txt - --file requirements/docs.txt - --quiet --yes - - - name: install the package - run: python -m pip install . --no-deps + conda config --set always_yes yes + --set changeps1 no + + - name: Install diffpy.pdfgui and build requirements + run: | + conda install --file requirements/build.txt + conda install --file requirements/run.txt + conda install --file requirements/docs.txt + python -m pip install -r requirements/pip.txt + python -m pip install . --no-deps - name: build documents run: make -C doc html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index c26194af..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: CI - -on: - push: - branches: - - main - - CI - pull_request: - workflow_dispatch: - -jobs: - miniconda: - name: Miniconda ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["ubuntu-latest"] - steps: - - name: check out diffpy.pdfgui - uses: actions/checkout@v3 - with: - repository: diffpy/diffpy.pdfgui - path: . - fetch-depth: 0 # avoid shallow clone with no tags - - - name: initialize miniconda - # this uses a marketplace action that sets up miniconda in a way that makes - # it easier to use. I tried setting it up without this and it was a pain - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: test - # environment.yml file is needed by this action. Because I don't want - # maintain this but rather maintain the requirements files it just has - # basic things in it like conda and pip - environment-file: ./environment.yml - python-version: 3 - auto-activate-base: false - - - name: install diffpy.pdfgui requirements - shell: bash -l {0} - run: | - conda config --set always_yes yes --set changeps1 no - conda config --add channels conda-forge - conda activate test - conda install --file requirements/run.txt - conda install --file requirements/test.txt - pip install . - - - name: Install Xvfb - run: sudo apt-get install -y xvfb - - - name: Start Xvfb - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate diffpy.pdfgui - shell: bash -l {0} - run: | - export DISPLAY=:99 - conda activate test - coverage run -m pytest -vv -s - coverage report -m - codecov diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml deleted file mode 100644 index f2ff7e42..00000000 --- a/.github/workflows/pre-commit.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: pre-commit - -on: - pull_request: - push: - workflow_dispatch: - -jobs: - pre-commit: - # pull requests are a duplicate of a branch push if within the same repo. - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - - uses: pre-commit/action@v3.0.0 - with: - extra_args: --all-files diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..1722ee0f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,52 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +defaults: + run: + shell: bash -l {0} + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Check out diffpy.pdfgui + uses: actions/checkout@v4 + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + auto-update-conda: true + environment-file: environment.yml + auto-activate-base: false + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install diffpy.pdfgui and requirements + run: | + conda install --file requirements/run.txt + conda install --file requirements/test.txt + python -m pip install -r requirements/pip.txt + python -m pip install . --no-deps + + - name: Install Xvfb + run: sudo apt-get install -y xvfb + + - name: Start Xvfb + run: | + export DISPLAY=:99 + Xvfb :99 -screen 0 1024x768x16 & + + - name: Validate diffpy.pdfgui + run: | + export DISPLAY=:99 + python -m pytest diff --git a/README.rst b/README.rst index b9d7da0a..f9f6b8a1 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,8 @@ .. |Black| image:: https://img.shields.io/badge/code_style-black-black :target: https://github.com/psf/black -.. |CI| image:: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml/badge.svg - :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml +.. |CI| image:: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/test.yml/badge.svg + :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/test.yml .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.pdfgui/branch/main/graph/badge.svg :target: https://codecov.io/gh/diffpy/diffpy.pdfgui From debe549511d0a6734c08299eb67b49608a7982e5 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Tue, 20 Aug 2024 02:56:49 -0400 Subject: [PATCH 2/3] remove prerelease from docs workflow --- .github/workflows/docs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e0fca501..624a7a66 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,6 @@ name: Build and Deploy Documentation on: release: types: - - prereleased - published workflow_dispatch: From 378f4e82b75654632514b49db74f8b1f78ca2696 Mon Sep 17 00:00:00 2001 From: Tieqiong Zhang Date: Tue, 20 Aug 2024 09:10:01 -0400 Subject: [PATCH 3/3] rename to main --- .github/workflows/{test.yml => main.yml} | 0 README.rst | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{test.yml => main.yml} (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/main.yml similarity index 100% rename from .github/workflows/test.yml rename to .github/workflows/main.yml diff --git a/README.rst b/README.rst index f9f6b8a1..b9d7da0a 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,8 @@ .. |Black| image:: https://img.shields.io/badge/code_style-black-black :target: https://github.com/psf/black -.. |CI| image:: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/test.yml/badge.svg - :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/test.yml +.. |CI| image:: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml/badge.svg + :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.pdfgui/branch/main/graph/badge.svg :target: https://codecov.io/gh/diffpy/diffpy.pdfgui