From f9aed94ce57fc0138af84926a0e59e73ebb19b6e Mon Sep 17 00:00:00 2001 From: Peter Kraus Date: Tue, 8 Oct 2024 19:22:59 +0200 Subject: [PATCH] Workflow changes. --- .github/workflows/before-job/action.yml | 13 ---- .github/workflows/build-job/action.yml | 9 --- .github/workflows/docs-job/action.yml | 9 --- .github/workflows/pull-request-commit.yml | 67 ++++--------------- .github/workflows/push-main.yml | 39 +++++++++++ .github/workflows/push-master.yml | 79 ----------------------- .github/workflows/test-job/action.yml | 10 --- .github/workflows/workflow-build.yml | 35 ++++++++++ .github/workflows/workflow-pages.yml | 39 +++++++++++ .github/workflows/workflow-test.yml | 42 ++++++++++++ 10 files changed, 168 insertions(+), 174 deletions(-) delete mode 100644 .github/workflows/before-job/action.yml delete mode 100644 .github/workflows/build-job/action.yml delete mode 100644 .github/workflows/docs-job/action.yml create mode 100644 .github/workflows/push-main.yml delete mode 100644 .github/workflows/push-master.yml delete mode 100644 .github/workflows/test-job/action.yml create mode 100644 .github/workflows/workflow-build.yml create mode 100644 .github/workflows/workflow-pages.yml create mode 100644 .github/workflows/workflow-test.yml diff --git a/.github/workflows/before-job/action.yml b/.github/workflows/before-job/action.yml deleted file mode 100644 index 5f94490..0000000 --- a/.github/workflows/before-job/action.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: "Before job script" -description: "Set up a python dev environment." -runs: - using: "composite" - steps: - - run: python -V - shell: bash - - run: pip install virtualenv - shell: bash - - run: virtualenv venv - shell: bash - - run: source venv/bin/activate || source venv/Scripts/activate - shell: bash diff --git a/.github/workflows/build-job/action.yml b/.github/workflows/build-job/action.yml deleted file mode 100644 index 4fb29f8..0000000 --- a/.github/workflows/build-job/action.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: "Build job" -description: "Build the package." -runs: - using: "composite" - steps: - - run: pip install wheel - shell: bash - - run: python setup.py bdist_wheel - shell: bash diff --git a/.github/workflows/docs-job/action.yml b/.github/workflows/docs-job/action.yml deleted file mode 100644 index 6b04340..0000000 --- a/.github/workflows/docs-job/action.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: "Docs build job" -description: "Build the documentation." -runs: - using: "composite" - steps: - - run: sphinx-apidoc -o docs/source/apidoc src/dgbowl_schemas -T -M -E -f -e --templatedir=docs/apidoc_t - shell: bash - - run: sphinx-build -b html docs/source public/master - shell: bash diff --git a/.github/workflows/pull-request-commit.yml b/.github/workflows/pull-request-commit.yml index f89d759..6100715 100644 --- a/.github/workflows/pull-request-commit.yml +++ b/.github/workflows/pull-request-commit.yml @@ -1,75 +1,34 @@ name: pull-request-commit on: pull_request: - branches: - - master + branches: ['main'] jobs: build: strategy: matrix: pyver: ['3.8', '3.9', '3.10'] os: ['ubuntu-latest', 'windows-latest'] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.pyver }} - - uses: ./.github/workflows/before-job - - uses: ./.github/workflows/build-job - - uses: actions/upload-artifact@v2 - with: - name: dist-${{ matrix.os }}-${{ matrix.pyver }} - path: dist + uses: ./.github/workflows/workflow-build.yml + with: + pyver: ${{ matrix.pyver }} + os: ${{ matrix.os }} test: needs: [build] strategy: matrix: pyver: ['3.8', '3.9', '3.10'] os: ['ubuntu-latest', 'windows-latest'] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.pyver }} - - uses: ./.github/workflows/before-job - - uses: actions/download-artifact@v2 - with: - name: dist-${{ matrix.os }}-${{ matrix.pyver }} - - uses: jannekem/run-python-script-action@v1 - with: - script: | - import os - import subprocess - fn = [f for f in os.listdir() if f.endswith('whl') and f.startswith('dgbowl')][0] - subprocess.run(["pip", "install", f"{fn}[testing]"]) - - uses: ./.github/workflows/test-job + uses: ./.github/workflows/workflow-test.yml + with: + pyver: ${{ matrix.pyver }} + os: ${{ matrix.os }} pages: needs: [build] strategy: matrix: pyver: ['3.9'] os: ['ubuntu-latest'] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.pyver }} - - uses: ./.github/workflows/before-job - - uses: actions/download-artifact@v2 - with: - name: dist-${{ matrix.os }}-${{ matrix.pyver }} - - uses: jannekem/run-python-script-action@v1 - with: - script: | - import os - import subprocess - fn = [f for f in os.listdir() if f.endswith('whl') and f.startswith('dgbowl')][0] - subprocess.run(["pip", "install", f"{fn}[docs]"]) - - uses: ./.github/workflows/docs-job - - uses: actions/upload-artifact@v2 - with: - name: public-${{ matrix.os }}-${{ matrix.pyver }} - path: public \ No newline at end of file + uses: ./.github/workflows/workflow-pages.yml + with: + pyver: ${{ matrix.pyver }} + os: ${{ matrix.os }} \ No newline at end of file diff --git a/.github/workflows/push-main.yml b/.github/workflows/push-main.yml new file mode 100644 index 0000000..7f2c3c6 --- /dev/null +++ b/.github/workflows/push-main.yml @@ -0,0 +1,39 @@ +name: push-main +on: + push: + branches: ['main'] +jobs: + build: + uses: ./.github/workflows/workflow-build.yml + with: + pyver: '3.9' + os: 'ubuntu-latest' + test: + needs: [build] + uses: ./.github/workflows/workflow-test.yml + with: + pyver: '3.9' + os: 'ubuntu-latest' + pages: + needs: [build] + uses: ./.github/workflows/workflow-pages.yml + with: + pyver: '3.9' + os: ubuntu-latest + deploy: + needs: [pages] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.9' + - uses: actions/download-artifact@v4 + with: + name: public-ubuntu-latest-3.9 + path: public/main + - uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./public + keep_files: true diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml deleted file mode 100644 index b75ee22..0000000 --- a/.github/workflows/push-master.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: push-master -on: - push: - branches: ['master'] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - uses: ./.github/workflows/before-job - - uses: ./.github/workflows/build-job - - uses: actions/upload-artifact@v2 - with: - name: dist-master - path: dist - test: - needs: [build] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - uses: ./.github/workflows/before-job - - uses: actions/download-artifact@v2 - with: - name: dist-master - - uses: jannekem/run-python-script-action@v1 - with: - script: | - import os - import subprocess - fn = [f for f in os.listdir() if f.endswith('whl') and f.startswith('dgbowl')][0] - subprocess.run(["pip", "install", f"{fn}[testing]"]) - - uses: ./.github/workflows/test-job - pages: - needs: [build] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - uses: ./.github/workflows/before-job - - uses: actions/download-artifact@v2 - with: - name: dist-master - - uses: jannekem/run-python-script-action@v1 - with: - script: | - import os - import subprocess - fn = [f for f in os.listdir() if f.endswith('whl') and f.startswith('dgbowl')][0] - subprocess.run(["pip", "install", f"{fn}[docs]"]) - - uses: ./.github/workflows/docs-job - - uses: actions/upload-artifact@v2 - with: - name: public-master - path: public/master - deploy: - needs: [pages] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - uses: actions/download-artifact@v2 - with: - name: public-master - path: public/master - - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./public - keep_files: true diff --git a/.github/workflows/test-job/action.yml b/.github/workflows/test-job/action.yml deleted file mode 100644 index 247b77d..0000000 --- a/.github/workflows/test-job/action.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: "Test job" -description: "Test the package with pytest." -runs: - using: "composite" - steps: - - name: Prepare locales - run: sudo locale-gen de_DE.UTF-8 en_GB.UTF-8 || echo windows - shell: bash - - run: pytest -vv - shell: bash diff --git a/.github/workflows/workflow-build.yml b/.github/workflows/workflow-build.yml new file mode 100644 index 0000000..eda4f22 --- /dev/null +++ b/.github/workflows/workflow-build.yml @@ -0,0 +1,35 @@ +--- +name: Build schemas +on: + workflow_call: + inputs: + os: + required: true + type: string + pyver: + required: true + type: string + +jobs: + build: + runs-on: ${{ inputs.os }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.pyver }} + - name: Install dependencies + shell: bash + run: | + python -m pip install --upgrade pip + pip install -U setuptools build + - name: Build dgbowl schemas + shell: bash + run: | + python -m build + - uses: actions/upload-artifact@v4 + with: + name: dist-${{ inputs.os }}-${{ inputs.pyver }} + path: dist \ No newline at end of file diff --git a/.github/workflows/workflow-pages.yml b/.github/workflows/workflow-pages.yml new file mode 100644 index 0000000..9f7be8b --- /dev/null +++ b/.github/workflows/workflow-pages.yml @@ -0,0 +1,39 @@ +--- +name: Build docs +on: + workflow_call: + inputs: + os: + required: true + type: string + pyver: + required: true + type: string + +jobs: + pages: + runs-on: ${{ inputs.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.pyver }} + - uses: actions/download-artifact@v4 + with: + name: dist-${{ inputs.os }}-${{ inputs.pyver }} + - uses: jannekem/run-python-script-action@v1 + with: + script: | + import os + import subprocess + fn = [f for f in os.listdir() if f.endswith('whl') and f.startswith('dgbowl_schemas')][0] + subprocess.run(["pip", "install", f"{fn}[docs]"]) + - name: Build the docs + shell: bash + run: | + sphinx-apidoc -o docs/source/apidoc src/yadg -T -M -f --templatedir=docs/apidoc_t + sphinx-build -W -b html docs/source public/main + - uses: actions/upload-artifact@v4 + with: + name: public-${{ inputs.os }}-${{ inputs.pyver }} + path: public/main diff --git a/.github/workflows/workflow-test.yml b/.github/workflows/workflow-test.yml new file mode 100644 index 0000000..0c79813 --- /dev/null +++ b/.github/workflows/workflow-test.yml @@ -0,0 +1,42 @@ +--- +name: Test schemas +on: + workflow_call: + inputs: + os: + required: true + type: string + pyver: + required: true + type: string + +jobs: + test: + runs-on: ${{ inputs.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.pyver }} + - uses: actions/download-artifact@v4 + with: + name: dist-${{ inputs.os }}-${{ inputs.pyver }} + - uses: jannekem/run-python-script-action@v1 + with: + script: | + import os + import subprocess + fn = [f for f in os.listdir() if f.endswith('whl') and f.startswith('dgbowl_schemas')][0] + subprocess.run(["pip", "install", f"{fn}[testing]"]) + - name: Prepare locales + shell: bash + run: sudo locale-gen de_DE.UTF-8 en_GB.UTF-8 || echo windows + - name: Prepare timezone + uses: szenius/set-timezone@v1.2 + with: + timezoneLinux: Europe/Berlin + timezoneMacos: Europe/Berlin + timezoneWindows: W. Europe Standard Time + - name: Run pytest + shell: bash + run: pytest -vv