From 52dc42504f623903e3cd8f964fdd998bf76e42bd Mon Sep 17 00:00:00 2001 From: Rubel Date: Tue, 19 Nov 2024 12:10:12 +0100 Subject: [PATCH] ci/cd workflow. --- .github/workflows/backward_compatibility.yml | 41 ++++++++++++++++++++ .github/workflows/build_docs.yml | 28 +++++++++++++ .github/workflows/publish.yml | 30 ++++++++++++++ .github/workflows/pylint.yml | 33 ++++++++++++++++ .github/workflows/pytest.yml | 34 ++++++++++++++++ .github/workflows/python-package.yml | 28 +++++++++++++ 6 files changed, 194 insertions(+) create mode 100644 .github/workflows/backward_compatibility.yml create mode 100644 .github/workflows/build_docs.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/pylint.yml create mode 100644 .github/workflows/pytest.yml create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/backward_compatibility.yml b/.github/workflows/backward_compatibility.yml new file mode 100644 index 0000000..ba3d30e --- /dev/null +++ b/.github/workflows/backward_compatibility.yml @@ -0,0 +1,41 @@ +name: Backward Compatibility with Pynxtools + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + backward_compatibility: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + pynxtools_versions: ["master"] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: recursive + - name: Set up Python 3.11 + uses: actions/setup-python@v2 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install coverage coveralls + - name: Install pynxtools-stm + run: | + pip install .[dev] + - name: Install pynxtools version ${{ matrix.pynxtools_versions }} + run: | + if [ "${{ matrix.pynxtools_versions }}" == "master" ]; then + pip install pynxtools@git+https://github.com/FAIRmat-NFDI/pynxtools@${{ matrix.pynxtools_versions }} + else + pip install pynxtools==${{ matrix.pynxtools_versions }} + fi + - name: Run tests + run: | + pytest tests/. \ No newline at end of file diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml new file mode 100644 index 0000000..209e9a0 --- /dev/null +++ b/.github/workflows/build_docs.yml @@ -0,0 +1,28 @@ +name: Build Docs +on: + push: + branches: + - main +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Configure Git Credentials + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: pip install .[docs] + - run: mkdocs gh-deploy --force \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..33e5e20 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,30 @@ +name: Upload Python Package + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{secrets.PYPI_API_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..630182c --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,33 @@ +name: linting + +on: [push] + +jobs: + linting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install dependencies + run: | + git submodule sync --recursive + git submodule update --init --recursive --jobs=4 + python -m pip install --upgrade pip + - name: Install package + run: | + python -m pip install --no-deps . + - name: Install requirements + run: | + python -m pip install -r dev-requirements.txt + - name: ruff + run: | + ruff pynxtools_stm tests + - name: ruff formatting + run: | + ruff format --check pynxtools_stm tests + - name: mypy + run: | + mypy pynxtools_stm tests \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..6e3b4fc --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,34 @@ +name: pytest + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + pytest: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + - name: Set up Python ${{matrix.python_version}} + uses: actions/setup-python@v4 + with: + python-version: ${{matrix.python_version}} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + - name: Install package + run: | + pip install ".[dev]" + - name: Test with pytest + run: | + pytest tests \ No newline at end of file diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..ffee541 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,28 @@ +name: pynxtools-stm package + +on: + push: + branches: [ ci_cd ] + pull_request: + branches: [ ci_cd ] + types: [opened, edited, synchronize, reopened] +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + - name: Test with pytest + run: | + python -m pytest tests