Use artefacts instead of cache to prevent race conditions while building #287
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Pythia | |
on: [push] | |
env: | |
PYTHON_VERSION: 3.10.9 | |
jobs: | |
Create-Interpreters: | |
runs-on: ${{ matrix.os }} | |
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: Download the interpreters | |
uses: actions/download-artifact@v3 | |
with: | |
name: _Internal_Python_Interpreters | |
- name: Create the directory | |
run: mkdir "@Pythia" | |
- 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 | |
# Note: we're running tests after uploading to make 100% sure we don't | |
# corrupt the environment by running tests. | |
# We could do this in another job but doing this here saves us a few seconds | |
- 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 }} | |
Build-PBO: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Cache tools | |
uses: actions/cache@v3 | |
with: | |
path: tools/cache | |
key: tools_cache | |
# Build PBOs and pack | |
- name: Install Mikero's tools | |
uses: arma-actions/mikero-tools@bec8b18fc507ee3180cadeaf35249d3f2702b1ff | |
- run: python tools/build.py build_pbos | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: _Internal_Pythia_PBOs | |
path: | | |
@Pythia/addons | |
@Pythia/keys | |
if-no-files-found: error | |
retention-days: 1 | |
Consolidate: | |
needs: | |
- Build-Binaries | |
- Build-PBO | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Download the binaries | |
uses: actions/download-artifact@v3 | |
with: | |
name: _Internal_Pythia_Binaries | |
path: "@Pythia" | |
- name: Download the PBOs | |
uses: actions/download-artifact@v3 | |
with: | |
name: _Internal_Pythia_PBOs | |
path: "@Pythia" | |
- name: Download the interpreters | |
uses: actions/download-artifact@v3 | |
with: | |
name: _Internal_Python_Interpreters | |
- name: Copy templates | |
run: python tools/build.py copy_templates ${{ env.PYTHON_VERSION }} | |
- name: Unpack interpreters | |
run: for i in python-*.tar; do tar xf "$i" --directory "@Pythia"; done | |
- run: pip install -r requirements.txt | |
- run: python tools/build.py safety_checks ${{ env.PYTHON_VERSION }} | |
- name: Remove linux 32bit Pythia | |
run: rm -rf @Pythia/python-*-embed-linux32 @Pythia/Pythia.so @Pythia/PythiaSetPythonPath.so @Pythia/PythiaTester @Pythia/install_requirements32.sh | |
- run: tar -jcf "@Pythia.tbz" "@Pythia" | |
- uses: actions/upload-artifact@v3 | |
# if: ${{ github.ref == 'refs/heads/master' }} | |
with: | |
name: Pythia | |
path: "@Pythia.tbz" | |
if-no-files-found: error | |
retention-days: 8 | |
# Deploy-dev: | |
# needs: | |
# - Consolidate | |
# runs-on: ubuntu-latest | |
# environment: Dev-deploy | |
# steps: | |
# - name: Download the release | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: Pythia | |
# | |
# - name: Unpack the release | |
# run: tar xf @Pythia.tbz | |
# | |
# - name: Upload to Workshop as Pythia-dev | |
# uses: arma-actions/workshop-upload@v1 | |
# if: github.event_name == 'push' && github.actor != 'depbot' | |
# with: | |
# appId: '107410' # default | |
# itemId: '2705521455' # ID of item to update | |
# contentPath: '@Pythia' | |
# changelog: 'Automatic push by CI' | |
# env: | |
# STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }} | |
# STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }} |