iced/.github/workflows/build.yml

489 lines
16 KiB
YAML

name: GitHub CI
on:
push:
paths:
- ".github/workflows/build.yml"
- "build/**"
- "src/**"
- "!**/*.md"
branches:
- master
pull_request:
paths:
- "build/**"
- "src/**"
- "!**/*.md"
branches:
- master
release:
types: [released]
env:
CI_REQ_DOTNET_SDK_VER: 5.0.100
COVERAGE_FILENAME: coverage.net5.0.info
CI_NODE_MIN_VER: 10.0.0
RUSTFLAGS: -D warnings
MACOSX_DEPLOYMENT_TARGET: 10.12
jobs:
#############################################################################
#############################################################################
#############################################################################
build-dotnet:
name: C# (${{matrix.os}})
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{env.CI_REQ_DOTNET_SDK_VER}}
- name: Build and test
shell: bash
run: |
extra_args=
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
extra_args=--quick-check
fi
./build/build-dotnet $extra_args
- uses: actions/upload-artifact@v2
if: startsWith(matrix.os, 'ubuntu-')
with:
name: nupkg
path: src/csharp/Intel/Iced/bin/Release/*.*nupkg
if-no-files-found: error
- uses: actions/upload-artifact@v2
if: startsWith(matrix.os, 'ubuntu-')
with:
name: coverage.info
path: src/csharp/Intel/Iced.UnitTests/${{env.COVERAGE_FILENAME}}
if-no-files-found: error
#############################################################################
#############################################################################
#############################################################################
build-rust:
name: Rust (${{matrix.os}})
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Install Rust
shell: bash
run: bash build/ci-install-rust.sh
- uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{env.CI_REQ_DOTNET_SDK_VER}}
- name: Build and test
shell: bash
run: |
extra_args=
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
extra_args=--quick-check
fi
./build/build-rust --no-set-rustflags $extra_args
#############################################################################
#############################################################################
#############################################################################
build-rust-js-wasm:
name: JavaScript (${{matrix.os}})
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Install Rust
shell: bash
run: bash build/ci-install-rust.sh
- uses: actions/setup-node@v1
with:
node-version: ${{env.CI_NODE_MIN_VER}}
- name: Install wasm-pack
shell: bash
run: npm install -g wasm-pack
- name: Build and test
shell: bash
run: |
extra_args=
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
extra_args=--quick-check
fi
./build/build-js --no-set-rustflags $extra_args
#############################################################################
#############################################################################
#############################################################################
build-rust-python:
name: Python (${{matrix.os}})
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Verify that py/LICENSE.txt matches root/LICENSE.txt
shell: bash
run: |
pydir=src/rust/iced-x86-py
if [ ! -f "$pydir/LICENSE.txt" ]; then
echo "Missing license file"
exit 1
fi
cp LICENSE.txt "$pydir/"
git diff --exit-code
- name: Install Rust
shell: bash
run: bash build/ci-install-rust.sh
- name: Use repo source code
shell: bash
run: |
# Make sure crates.io isn't used
if [ "$OSTYPE" = "msys" ]; then
echo "paths = [\"$(pwd -W)/src/rust/iced-x86\"]" > "$HOME/.cargo/config.toml"
else
echo "paths = [\"$(pwd)/src/rust/iced-x86\"]" > "$HOME/.cargo/config.toml"
fi
# If the supported Python versions get updated (added/removed), do:
# - Update .github/workflows/build.yml (this file)
# - Search for eg. 3.9, 39 and 3\.9
# - Update file count in `Verify downloads`
# - Update min ver in build/README.md and src/rust/iced-x86-py/README.md
# - Update src/rust/iced-x86-py/build-wheels.sh (search for eg. 39)
# - Update Python versions in src/rust/iced-x86-py/setup.py
# - `python_requires` line
# - `classifiers` array
# - src/rust/iced-x86-py/tox.ini
#
# NOTE: We use setup-miniconda and not setup-python because setup-python's
# binaries target a later macos version and will produce warnings
# when building wheels on macos.
# https://github.com/actions/setup-python/issues/26
# This also means that all bash shells (that use Python) must
# use the -le options:
# shell: bash -le {0}
# setup-python is faster to install than setup-miniconda so we only
# use setup-miniconda if this is a macos image.
- uses: actions/setup-python@v2
if: "!startsWith(matrix.os, 'macos-')"
with:
python-version: 3.6
- uses: conda-incubator/setup-miniconda@v2
if: startsWith(matrix.os, 'macos-')
with:
python-version: 3.6
- name: Install Python tools
shell: bash -le {0}
run: |
python --version 2>&1 | grep "Python 3\.6"
python -m pip install -r src/rust/iced-x86-py/requirements-dev.txt
- name: Build and test
shell: bash -le {0}
run: |
extra_args=
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
extra_args=--quick-check
fi
./build/build-python --no-set-rustflags --python python $extra_args
git clean -xdf
- name: Create the sdist
if: startsWith(matrix.os, 'ubuntu-')
shell: bash -le {0}
run: |
git clean -xdf
./build/build-python --sdist-only
mkdir -p /tmp/py-dist
cp src/rust/iced-x86-py/dist/* /tmp/py-dist
git clean -xdf
####################### BEGIN Python Wheel: Linux, manylinux docker image #######################
# https://github.com/pypa/manylinux
- name: Download manylinux docker image
if: startsWith(matrix.os, 'ubuntu-')
shell: bash
run: |
# Update py-build-wheels-linux.sh if the image name is updated
docker pull quay.io/pypa/manylinux2010_x86_64
- name: Use manylinux docker image to build Linux wheels
if: startsWith(matrix.os, 'ubuntu-')
shell: bash -le {0}
run: |
git clean -xdf
./build/py-build-wheels-linux.sh
git clean -xdf
####################### END Python Wheel: Linux, manylinux docker image #######################
####################### BEGIN Python Wheel: !Linux #######################
#########################################################################
# NOTE: See the comment above before adding/removing new Python versions
#########################################################################
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.6
- uses: conda-incubator/setup-miniconda@v2
if: startsWith(matrix.os, 'macos-')
with:
python-version: 3.6
- name: Build the wheel
if: "!startsWith(matrix.os, 'ubuntu-')"
shell: bash -le {0}
run: |
python --version 2>&1 | grep "Python 3\.6"
bash build/ci-py-build-wheels.sh
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.7
- uses: conda-incubator/setup-miniconda@v2
if: startsWith(matrix.os, 'macos-')
with:
python-version: 3.7
- name: Build the wheel
if: "!startsWith(matrix.os, 'ubuntu-')"
shell: bash -le {0}
run: |
python --version 2>&1 | grep "Python 3\.7"
bash build/ci-py-build-wheels.sh
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.8
- uses: conda-incubator/setup-miniconda@v2
if: startsWith(matrix.os, 'macos-')
with:
python-version: 3.8
- name: Build the wheel
if: "!startsWith(matrix.os, 'ubuntu-')"
shell: bash -le {0}
run: |
python --version 2>&1 | grep "Python 3\.8"
bash build/ci-py-build-wheels.sh
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.9
- uses: conda-incubator/setup-miniconda@v2
if: startsWith(matrix.os, 'macos-')
with:
python-version: 3.9
- name: Build the wheel
if: "!startsWith(matrix.os, 'ubuntu-')"
shell: bash -le {0}
run: |
python --version 2>&1 | grep "Python 3\.9"
bash build/ci-py-build-wheels.sh
#########################################################################
# The rest of the code needs 32-bit Rust/Python
#########################################################################
- name: Install 32-bit Rust
if: startsWith(matrix.os, 'windows-')
shell: bash
run: |
rustup install stable-i686-pc-windows-msvc --no-self-update
rustup default stable-i686-pc-windows-msvc
rustup show
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.6
architecture: x86
- name: Build the wheel
if: startsWith(matrix.os, 'windows-')
shell: bash
run: |
python --version 2>&1 | grep "Python 3\.6"
bash build/ci-py-build-wheels.sh
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.7
architecture: x86
- name: Build the wheel
if: startsWith(matrix.os, 'windows-')
shell: bash
run: |
python --version 2>&1 | grep "Python 3\.7"
bash build/ci-py-build-wheels.sh
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.8
architecture: x86
- name: Build the wheel
if: startsWith(matrix.os, 'windows-')
shell: bash
run: |
python --version 2>&1 | grep "Python 3\.8"
bash build/ci-py-build-wheels.sh
- uses: actions/setup-python@v2
if: startsWith(matrix.os, 'windows-')
with:
python-version: 3.9
architecture: x86
- name: Build the wheel
if: startsWith(matrix.os, 'windows-')
shell: bash
run: |
python --version 2>&1 | grep "Python 3\.9"
bash build/ci-py-build-wheels.sh
####################### END Python Wheel: !Linux #######################
- name: Fix upload path
shell: bash
run: |
git clean -xdf
cp -r /tmp/py-dist .
- uses: actions/upload-artifact@v2
with:
name: py-dist-${{matrix.os}}
path: py-dist
if-no-files-found: error
#############################################################################
#############################################################################
#############################################################################
upload-files:
runs-on: ubuntu-latest
name: Upload files
needs:
- build-dotnet
- build-rust
- build-rust-js-wasm
- build-rust-python
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{env.CI_REQ_DOTNET_SDK_VER}}
- uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/download-artifact@v2
with:
path: /tmp/artifacts
- name: Verify downloads
shell: bash
run: |
if [ ! -f "/tmp/artifacts/coverage.info/$COVERAGE_FILENAME" ]; then
echo "Missing coverage"
exit 1
fi
if [ -z "$(ls -A /tmp/artifacts/nupkg/Iced.*.nupkg)" ]; then
echo "Missing nupkg files"
exit 1
fi
mkdir /tmp/py-dist-tmp
mkdir /tmp/py-dist
for path in /tmp/artifacts/py-dist-*; do
cp "$path/"* /tmp/py-dist-tmp
done
supported_py_versions=(36 37 38 39)
for py_ver in ${supported_py_versions[@]}; do
mv /tmp/py-dist-tmp/iced_x86-*-cp${py_ver}-cp${py_ver}*.whl /tmp/py-dist
done
mv /tmp/py-dist-tmp/iced-x86-*.tar.gz /tmp/py-dist
for file in /tmp/py-dist-tmp/*; do
if [ -f "$file" ]; then
ls -l /tmp/py-dist-tmp
echo "Unknown files found (see above)"
echo "If it's a new Python version, see Python version comment above (`build-rust-python`)"
exit 1
fi
done
rmdir /tmp/py-dist-tmp
# (4+1) (supported platforms) * 4 (supported Python versions) + 1 (source code tar.gz file)
# (^+1 == manylinux build creates manylinux1 + manylinux2010 files)
if [ $(ls -A /tmp/py-dist | wc -l) -ne 21 ]; then
ls -l /tmp/py-dist
echo "Found too many/few Python whl files (see above)"
exit 1
fi
- name: Upload checks
shell: bash
run: |
python -m pip install -U twine
twine check /tmp/py-dist/*
dotnet nuget push --help
cargo publish --help
- name: Upload coverage report
if: github.ref == 'refs/heads/master'
shell: bash
continue-on-error: true
run: |
curl --proto '=https' --tlsv1.2 -sSf https://codecov.io/bash | bash -s -- -f "/tmp/artifacts/coverage.info/$COVERAGE_FILENAME"
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
- name: Upload to nuget.org
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
for file in /tmp/artifacts/nupkg/Iced.*.nupkg; do
dotnet nuget push "$file" --api-key "${{secrets.NUGET_APIKEY}}" --source https://api.nuget.org/v3/index.json
done
- name: Upload to crates.io
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
git clean -xdf
git checkout .
cd src/rust/iced-x86
cargo login --color always -- "${{secrets.CRATES_IO_TOKEN}}"
# --no-verify: we've tested building everything already
cargo publish --color always --no-verify