From e007c9bb40f84c36478c57e0b487bcd24c04dba2 Mon Sep 17 00:00:00 2001 From: Uwe Fladrich <49554848+uwefladrich@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:32:04 +0200 Subject: [PATCH] Fix #72: Release pipeline (#73) * Style changes * Add install-from-source action * Add second se run for logging * Add test for package build * Change action name * Add publish and test action * Remove cron schedule for pytest action --- .github/workflows/build-package.yml | 28 +++++ .github/workflows/install-from-source.yml | 45 +++++++ .github/workflows/publish-to-pypi.yml | 70 +++++++++++ .github/workflows/pytest.yml | 145 +++++++++++----------- 4 files changed, 216 insertions(+), 72 deletions(-) create mode 100644 .github/workflows/build-package.yml create mode 100644 .github/workflows/install-from-source.yml create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml new file mode 100644 index 0000000..cbed56d --- /dev/null +++ b/.github/workflows/build-package.yml @@ -0,0 +1,28 @@ +name: Test building PyPI package +on: + push: + +jobs: + pytest: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] + + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: ${{matrix.python-version}} + - + name: Install pypa/build + run: | + python -m pip install --upgrade pip + python -m pip install build + - + name: Build binary wheel and source tarbal + run: python -m build --sdist --wheel --outdir dist/ . diff --git a/.github/workflows/install-from-source.yml b/.github/workflows/install-from-source.yml new file mode 100644 index 0000000..6787679 --- /dev/null +++ b/.github/workflows/install-from-source.yml @@ -0,0 +1,45 @@ +name: Install from source +on: + push: + +jobs: + pytest: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + strategy: + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] + + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: ${{matrix.python-version}} + - + name: Setup miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + auto-activate-base: true + environment-file: conda_environment.yml + python-version: ${{matrix.python-version}} + - + name: Finish conda setup + run: | + conda info + conda install pip + python -m pip install --upgrade pip + - + name: Install package + remaining PyPI dependencies + run: pip install . + - + name: Test run ScriptEngine + run: | + se --help + se --help | grep -q "ece\.mon" diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..50297ed --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,70 @@ +name: Package, publish to and test from PyPI +on: + push: + tags: + - "*" + +jobs: + build-n-publish: + runs-on: ubuntu-latest + + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: 3.9 + - + name: Install pypa/build + run: | + python -m pip install --upgrade pip + python -m pip install build + - + name: Build binary wheel and source tarbal + run: python -m build --sdist --wheel --outdir dist/ . + - + name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + + test-from-pypi: + needs: build-n-publish + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] + steps: + - + name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: ${{matrix.python-version}} + - + name: Setup miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + auto-activate-base: true + environment-file: conda_environment.yml + python-version: ${{matrix.python-version}} + - + name: Finish conda setup + run: | + conda info + conda install pip + python -m pip install --upgrade pip + - + name: Install dependencies and scriptengine-tasks-ecearth + run: | + python -m pip install --upgrade pip + python -m pip install scriptengine-tasks-ecearth + - + name: Test run ScriptEngine + run: | + se --help + se --help | grep -q "ece\.mon" diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 7171a47..95963d2 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,7 +1,5 @@ -name: PyTest -on: - schedule: - - cron: '0 8 * * *' +name: Run pytest and coverage +on: push: env: @@ -9,72 +7,75 @@ env: TEST_DATA_DOWNLOAD: "test-data" jobs: - pytest: - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - strategy: - matrix: - python-version: [ '3.7', '3.8', '3.9', '3.10' ] + pytest: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + strategy: + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v3 - with: - python-version: ${{matrix.python-version}} - - - name: Setup miniconda - uses: conda-incubator/setup-miniconda@v2 - with: - miniconda-version: "latest" - auto-activate-base: true - environment-file: conda_environment.yml - python-version: ${{matrix.python-version}} - - - name: Finish conda setup - run: | - conda info - conda install pip - python -m pip install --upgrade pip - conda list - - - name: Install package + remaining PyPI dependencies - run: pip install . - - - name: Download test data - run: | - mkdir ${TEST_DATA_DOWNLOAD}; - wget -O ${TEST_DATA_DOWNLOAD}/test-data.zip ${TEST_DATA_REF}; - unzip -q ${TEST_DATA_DOWNLOAD}/test-data.zip -d ${TEST_DATA_DOWNLOAD}; - mv ${TEST_DATA_DOWNLOAD}/ece-4-monitoring-test-data-main/ tests/testdata; - - - name: Install dependencies for testing - run: | - python -m pip install pytest - python -m pip install coverage - python -m pip install coveralls - python -m pip install flake8 - - name: Lint with flake8 - run: | - # Syntax errors or undefined names - flake8 --count --select=E9,F63,F7,F82 --show-source --statistics monitoring/ - flake8 --count --select=E9,F63,F7,F82 --show-source --statistics helpers/ - flake8 --count --select=E9,F63,F7,F82 --show-source --statistics tests/ - # All other stuff - flake8 --exit-zero --count --statistics --exclude=__init__.py --max-line-length=88 monitoring/ - flake8 --exit-zero --count --statistics --exclude=__init__.py --max-line-length=88 helpers/ - flake8 --exit-zero --count --statistics --exclude=__init__.py --max-line-length=88 tests/ - - name: Run PyTest - run: | - coverage run -m pytest - coverage lcov - - - name: Run Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: coverage.lcov + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Setup Python + uses: actions/setup-python@v3 + with: + python-version: ${{matrix.python-version}} + - + name: Setup miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + auto-activate-base: true + environment-file: conda_environment.yml + python-version: ${{matrix.python-version}} + - + name: Finish conda setup + run: | + conda info + conda install pip + python -m pip install --upgrade pip + conda list + - + name: Install package + remaining PyPI dependencies + run: pip install . + - + name: Download test data + run: | + mkdir ${TEST_DATA_DOWNLOAD}; + wget -O ${TEST_DATA_DOWNLOAD}/test-data.zip ${TEST_DATA_REF}; + unzip -q ${TEST_DATA_DOWNLOAD}/test-data.zip -d ${TEST_DATA_DOWNLOAD}; + mv ${TEST_DATA_DOWNLOAD}/ece-4-monitoring-test-data-main/ tests/testdata; + - + name: Install dependencies for testing + run: | + python -m pip install pytest + python -m pip install coverage + python -m pip install coveralls + python -m pip install flake8 + - + name: Lint with flake8 + run: | + # Syntax errors or undefined names + flake8 --count --select=E9,F63,F7,F82 --show-source --statistics monitoring/ + flake8 --count --select=E9,F63,F7,F82 --show-source --statistics helpers/ + flake8 --count --select=E9,F63,F7,F82 --show-source --statistics tests/ + # All other stuff + flake8 --exit-zero --count --statistics --exclude=__init__.py --max-line-length=88 monitoring/ + flake8 --exit-zero --count --statistics --exclude=__init__.py --max-line-length=88 helpers/ + flake8 --exit-zero --count --statistics --exclude=__init__.py --max-line-length=88 tests/ + - + name: Run PyTest + run: | + coverage run -m pytest + coverage lcov + - + name: Run Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage.lcov