Skip to content

Commit

Permalink
Make CI not wait for unelated parallel build
Browse files Browse the repository at this point in the history
- Split OS-dependent steps to a separate sub-pipeline, so they can run without
  waiting for each other.
  • Loading branch information
gbdlin committed Jul 1, 2023
1 parent e27a94f commit 7891216
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 134 deletions.
145 changes: 145 additions & 0 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Build Pythia binaries
on:
workflow_call:
inputs:
os:
description: "OS to run the build for"
outputs:
image:
description: "Resulting docker image (tagged with commit SHA)"
value: ${{ jobs.set_image_name.outputs.image }}
env:
PYTHON_VERSION: 3.10.9
jobs:
Create-Interpreters:
runs-on: ${{ inputs.os }}

steps:
- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Cache interpreters
uses: actions/cache@v3
id: cache
with:
path: python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar
key: interpreters-${{ env.PYTHON_VERSION }}-${{ runner.os }}-${{ secrets.CACHE_VERSION }}

- name: Check out repository code
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v3

- name: Install requirements
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements.txt

- name: Create interpreters
if: steps.cache.outputs.cache-hit != 'true'
run: python tools/build.py create_interpreters ${{ env.PYTHON_VERSION }} --dest .

- name: Tar interpreters
if: steps.cache.outputs.cache-hit != 'true'
run: tar cvf python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar python-*-embed-*

- uses: actions/upload-artifact@v3
with:
name: _Internal_Python_Interpreters
path: python-*.tar
if-no-files-found: error
retention-days: 1

Build-Binaries:
needs: Create-Interpreters
runs-on: ${{ inputs.os }}
strategy:
fail-fast: false
matrix:
arch: [x64, x86]

steps:
- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Check out repository code
uses: actions/checkout@v3

- name: Create the directory
run: mkdir "@Pythia"

- name: Download the interpreters
uses: actions/download-artifact@v3
with:
name: _Internal_Python_Interpreters

- name: Untar the interpreter
run: tar xf ../python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar
working-directory: "@Pythia"

# Build the extension
- uses: ilammy/msvc-dev-cmd@v1
if: ${{ runner.os == 'Windows' }}
with:
arch: ${{ matrix.arch }}

- name: Perform build
run: python tools/build.py build_binaries ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}

- uses: actions/upload-artifact@v3
with:
name: _Internal_Pythia_Binaries
path: |
@Pythia/*.dll
@Pythia/*.so
@Pythia/*.exe
@Pythia/PythiaTester*
if-no-files-found: error
retention-days: 1

Test-Binaries:
needs: Build-Binaries
runs-on: ${{ inputs.os }}
strategy:
fail-fast: false
matrix:
arch: [x64, x86]

steps:
- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Check out repository code
uses: actions/checkout@v3

- name: Create the directory
run: mkdir "@Pythia"

- name: Download the interpreters
uses: actions/download-artifact@v3
with:
name: _Internal_Python_Interpreters

- name: Untar the interpreter
run: tar xf ../python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar
working-directory: "@Pythia"

- name: Download the binaries
uses: actions/download-artifact@v3
with:
name: _Internal_Pythia_Binaries
path: "@Pythia"

- name: Set testers permissions
run: chmod a+x @Pythia/PythiaTester*

- name: Install multilib for compiling 32bit Cython extensions (in tests)
if: runner.os == 'Linux' && matrix.arch == 'x86'
run: sudo apt install -y gcc-multilib

- name: Copy templates
run: python tools/build.py copy_templates ${{ env.PYTHON_VERSION }}

- name: Run basic tests
run: python tools/build.py run_tests ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}
138 changes: 4 additions & 134 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,95 +3,13 @@ on: [push]
env:
PYTHON_VERSION: 3.10.9
jobs:
Create-Interpreters:
runs-on: ${{ matrix.os }}
Build-binaries:
strategy:
matrix:
os: [windows-2019, ubuntu-20.04]

steps:
- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Cache interpreters
uses: actions/cache@v3
id: cache
with:
path: python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar
key: interpreters-${{ env.PYTHON_VERSION }}-${{ runner.os }}-${{ secrets.CACHE_VERSION }}

- name: Check out repository code
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v3

- name: Install requirements
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements.txt

- name: Create interpreters
if: steps.cache.outputs.cache-hit != 'true'
run: python tools/build.py create_interpreters ${{ env.PYTHON_VERSION }} --dest .

- name: Tar interpreters
if: steps.cache.outputs.cache-hit != 'true'
run: tar cvf python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar python-*-embed-*

- uses: actions/upload-artifact@v3
with:
name: _Internal_Python_Interpreters
path: python-*.tar
if-no-files-found: error
retention-days: 1

Build-Binaries:
needs: Create-Interpreters
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019, ubuntu-20.04]
arch: [x64, x86]

steps:
- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Check out repository code
uses: actions/checkout@v3

- name: Create the directory
run: mkdir "@Pythia"

- name: Download the interpreters
uses: actions/download-artifact@v3
with:
name: _Internal_Python_Interpreters

- name: Untar the interpreter
run: tar xf ../python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar
working-directory: "@Pythia"

# Build the extension
- uses: ilammy/msvc-dev-cmd@v1
if: ${{ runner.os == 'Windows' }}
with:
arch: ${{ matrix.arch }}

- name: Perform build
run: python tools/build.py build_binaries ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}

- uses: actions/upload-artifact@v3
with:
name: _Internal_Pythia_Binaries
path: |
@Pythia/*.dll
@Pythia/*.so
@Pythia/*.exe
@Pythia/PythiaTester*
if-no-files-found: error
retention-days: 1
uses: ./.github/workflows/build-binaries.yml
with:
os: ${{ matrix.os }}

Build-PBO:
runs-on: windows-latest
Expand Down Expand Up @@ -124,54 +42,6 @@ jobs:
if-no-files-found: error
retention-days: 1

Test-Binaries:
needs: Build-Binaries
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019, ubuntu-20.04]
arch: [x64, x86]

steps:
- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Check out repository code
uses: actions/checkout@v3

- name: Create the directory
run: mkdir "@Pythia"

- name: Download the interpreters
uses: actions/download-artifact@v3
with:
name: _Internal_Python_Interpreters

- name: Untar the interpreter
run: tar xf ../python-${{ env.PYTHON_VERSION }}-${{ runner.os }}.tar
working-directory: "@Pythia"

- name: Download the binaries
uses: actions/download-artifact@v3
with:
name: _Internal_Pythia_Binaries
path: "@Pythia"

- name: Set testers permissions
run: chmod a+x @Pythia/PythiaTester*

- name: Install multilib for compiling 32bit Cython extensions (in tests)
if: runner.os == 'Linux' && matrix.arch == 'x86'
run: sudo apt install -y gcc-multilib

- name: Copy templates
run: python tools/build.py copy_templates ${{ env.PYTHON_VERSION }}

- name: Run basic tests
run: python tools/build.py run_tests ${{ env.PYTHON_VERSION }} ${{ matrix.arch }} ${{ runner.os }}

Consolidate:
needs:
- Create-Interpreters
Expand Down

0 comments on commit 7891216

Please sign in to comment.