From 3920ae52f74175056da333f4b625f7dd87468c3a Mon Sep 17 00:00:00 2001 From: geisserml Date: Mon, 30 Oct 2023 23:40:55 +0100 Subject: [PATCH] Start working on CI --- .github/workflows/conda.yaml | 111 ++++++++++++++++++ .github/workflows/conda_bundle.yaml | 1 + .github/workflows/gh_pages.yaml | 4 - .../{build_packages.yaml => main.yaml} | 2 +- .github/workflows/test_release.yaml | 2 +- .github/workflows/trigger_conda_raw.yaml | 1 + ...trigger_release.yaml => trigger_main.yaml} | 6 +- setupsrc/pypdfium2_setup/craft_packages.py | 3 +- 8 files changed, 118 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/conda.yaml create mode 100644 .github/workflows/conda_bundle.yaml rename .github/workflows/{build_packages.yaml => main.yaml} (99%) create mode 100644 .github/workflows/trigger_conda_raw.yaml rename .github/workflows/{trigger_release.yaml => trigger_main.yaml} (94%) diff --git a/.github/workflows/conda.yaml b/.github/workflows/conda.yaml new file mode 100644 index 000000000..b92cd4277 --- /dev/null +++ b/.github/workflows/conda.yaml @@ -0,0 +1,111 @@ +# SPDX-FileCopyrightText: 2023 geisserml +# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause + +name: Conda packaging +on: + workflow_dispatch: + inputs: + publish: + default: false + type: boolean + test: + default: true + type: boolean + py_version: + default: '3.11' + type: string + package: + type: choice + options: + - raw + - helpers + +defaults: + run: + shell: bash + +jobs: + + build: + + runs-on: ubuntu-latest + steps: + + - name: Check out repository + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + fetch-depth: 0 + + - name: Miniconda setup + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: ${{ inputs.py_version }} + + - name: Prepare deps + run: | + conda install -y conda-build anaconda-client + conda config --prepend channels bblanchon + conda config --prepend channels pypdfium2-team + conda config --set channel_priority strict + + - name: Build package + run: ./run craft conda_${{ inputs.package }} + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: conda_package + path: conda/${{ inputs.package }}/out/*.tar.bz2 + + test: + + if: ${{ inputs.test }} + needs: build + + strategy: + fail-fast: false + matrix: + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + py: ['3.8', '3.9', '3.10', '3.11'] + + runs-on: ${{ matrix.os }} + + steps: + + - name: Check out repository + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + + - name: Miniconda setup + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: ${{ matrix.py }} + + - name: Prepare deps + run: | + conda config --prepend channels bblanchon + conda config --set channel_priority strict + + - name: Download packages + uses: actions/download-artifact@v3 + with: + name: conda_package + path: conda/${{ inputs.package }}/out/ + + - name: Install + run: conda install -c local -c bblanchon -c pypdfium2-team conda/${{ inputs.package }}/out/*.tar.bz2 + + - name: Test raw package + if: inputs.package == 'raw' + run: python3 conda/raw/minitest.py + + - name: Test helpers package + if: inputs.package == 'raw' + run: ./run test + + # publish: + # TODO diff --git a/.github/workflows/conda_bundle.yaml b/.github/workflows/conda_bundle.yaml new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/.github/workflows/conda_bundle.yaml @@ -0,0 +1 @@ + diff --git a/.github/workflows/gh_pages.yaml b/.github/workflows/gh_pages.yaml index a052bd21b..d4f775b88 100644 --- a/.github/workflows/gh_pages.yaml +++ b/.github/workflows/gh_pages.yaml @@ -25,10 +25,6 @@ concurrency: group: "pages" cancel-in-progress: true -defaults: - run: - shell: bash - jobs: build: diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/main.yaml similarity index 99% rename from .github/workflows/build_packages.yaml rename to .github/workflows/main.yaml index c4f6e13df..89bd90f76 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/main.yaml @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: 2023 geisserml # SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause -name: Build Packages +name: Main packaging on: workflow_dispatch: inputs: diff --git a/.github/workflows/test_release.yaml b/.github/workflows/test_release.yaml index f95d961d7..ea19259a3 100644 --- a/.github/workflows/test_release.yaml +++ b/.github/workflows/test_release.yaml @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: 2023 geisserml # SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause -name: Test Release +name: Test PyPI Release on: workflow_dispatch: inputs: diff --git a/.github/workflows/trigger_conda_raw.yaml b/.github/workflows/trigger_conda_raw.yaml new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/.github/workflows/trigger_conda_raw.yaml @@ -0,0 +1 @@ + diff --git a/.github/workflows/trigger_release.yaml b/.github/workflows/trigger_main.yaml similarity index 94% rename from .github/workflows/trigger_release.yaml rename to .github/workflows/trigger_main.yaml index ff67b18b9..f42612716 100644 --- a/.github/workflows/trigger_release.yaml +++ b/.github/workflows/trigger_main.yaml @@ -3,7 +3,7 @@ # Separate trigger workflow because we can't configure inputs for scheduled workflow runs (and don't want publish enabled by default in the main workflow) -name: Trigger Release +name: Trigger main release on: # https://github.com/bblanchon/pdfium-binaries/blob/master/.github/workflows/trigger.yml # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule @@ -13,10 +13,6 @@ on: # - cron: '0 4 * * 2' # old weekly schedule workflow_dispatch: -defaults: - run: - shell: bash - jobs: release: diff --git a/setupsrc/pypdfium2_setup/craft_packages.py b/setupsrc/pypdfium2_setup/craft_packages.py index 6c9f8088c..def15fb18 100644 --- a/setupsrc/pypdfium2_setup/craft_packages.py +++ b/setupsrc/pypdfium2_setup/craft_packages.py @@ -20,6 +20,7 @@ P_CONDA_RAW = "conda_raw" P_CONDA_HELPERS = "conda_helpers" +CondaChannels = ("-c", "local", "-c", "bblanchon", "-c", "pypdfium2-team") CondaDir = ProjectDir / "conda" @@ -109,7 +110,7 @@ def __exit__(self, *_): def run_conda_build(recipe_dir, out_dir, args=[]): with TmpCommitCtx(): - run_cmd(["conda", "build", recipe_dir, "--output-folder", out_dir, *args], cwd=ProjectDir, env=os.environ) + run_cmd(["conda", "build", *CondaChannels, recipe_dir, "--output-folder", out_dir, *args], cwd=ProjectDir, env=os.environ) CondaNames = {