mirror of https://github.com/Nonannet/copapy.git
387 lines
11 KiB
YAML
387 lines
11 KiB
YAML
name: CI Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main, dev]
|
|
|
|
jobs:
|
|
build_stencils:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/nonannet/cross_compiler_unix:2
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build & test aux functions
|
|
run: bash tools/test_stencil_aux.sh
|
|
|
|
- name: Build object files
|
|
run: bash tools/crosscompile.sh
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj/*.o
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: musl-object-files
|
|
path: /object_files/*
|
|
|
|
build-package-test:
|
|
needs: [build_stencils]
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.12"]
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: musl-object-files
|
|
path: /tmp/musl-object-files
|
|
|
|
- name: Add musl copyright notice to license file
|
|
run: |
|
|
echo "\n\nMUSL COPYRIGHT NOTICE:" >> LICENSE
|
|
cat /tmp/musl-object-files/COPYRIGHT >> LICENSE
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
python -m pip install .
|
|
python -m pip install pytest
|
|
|
|
- name: Vendor pelfy
|
|
run: |
|
|
git clone --depth 1 https://github.com/Nonannet/pelfy.git /tmp/pelfy
|
|
mkdir -p src/${{ github.event.repository.name }}/_vendor
|
|
cp -r /tmp/pelfy/src/pelfy src/${{ github.event.repository.name }}/_vendor/
|
|
|
|
- name: Run tests with pytest
|
|
run: pytest -m "not runner"
|
|
|
|
build-ubuntu:
|
|
needs: [build_stencils]
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.10"]
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install Python dependencies
|
|
run: python -m pip install .[dev]
|
|
|
|
- name: Compile coparun
|
|
run: |
|
|
mkdir -p build/runner
|
|
gcc -O3 -DENABLE_BASIC_LOGGING -o build/runner/coparun src/coparun/runmem.c src/coparun/coparun.c src/coparun/mem_man.c
|
|
|
|
- name: Generate debug asm files
|
|
if: strategy.job-index == 0
|
|
run: |
|
|
set -e
|
|
set -v
|
|
bash tools/create_asm.sh
|
|
|
|
echo '<p>example</p>' >> $GITHUB_STEP_SUMMARY
|
|
python tools/clean_asm.py build/runner/example.asm >> $GITHUB_STEP_SUMMARY
|
|
|
|
echo '<p>stencils_x86_64_O3.o</p>' >> $GITHUB_STEP_SUMMARY
|
|
python tools/clean_asm.py build/runner/stencils.asm >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Run tests with pytest
|
|
run: pytest
|
|
|
|
- name: Type checking with mypy
|
|
run: mypy
|
|
|
|
#- name: Lint code with flake8
|
|
# run: flake8
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
if: strategy.job-index == 0
|
|
with:
|
|
name: runner-linux-x86_64
|
|
path: build/runner/*
|
|
|
|
build-arm64:
|
|
needs: [build_stencils]
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj
|
|
- name: Set up QEMU for ARM64
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: linux/arm64
|
|
- name: Use ARM64 container
|
|
run: |
|
|
docker run --rm -v $PWD:/app -w /app --platform linux/arm64 ghcr.io/nonannet/arm64_test:1 \
|
|
bash -lc "pip install . && \
|
|
mkdir -p build/runner && \
|
|
gcc -O3 -DENABLE_LOGGING -o build/runner/coparun src/coparun/runmem.c \
|
|
src/coparun/coparun.c src/coparun/mem_man.c && \
|
|
pytest && \
|
|
bash tools/create_asm.sh"
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: runner-linux-arm64
|
|
path: build/runner/*
|
|
|
|
build-armv6:
|
|
needs: [build_stencils]
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj
|
|
- name: Set up QEMU for ARMv6
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: linux/arm/v6
|
|
- name: Use ARMv6 container
|
|
run: |
|
|
docker run --rm -v $PWD:/app -w /app --platform linux/arm/v6 ghcr.io/nonannet/armv6_test:1 \
|
|
bash -lc "pip install . && \
|
|
mkdir -p build/runner && \
|
|
gcc -O3 -DENABLE_LOGGING -o build/runner/coparun src/coparun/runmem.c \
|
|
src/coparun/coparun.c src/coparun/mem_man.c && \
|
|
pytest && \
|
|
bash tools/create_asm.sh"
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: runner-linux-armv6
|
|
path: build/runner/*
|
|
|
|
build-armv7:
|
|
needs: [build_stencils]
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj
|
|
- name: Set up QEMU for ARMv7
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: linux/arm/v7
|
|
- name: Use ARMv7 container
|
|
run: |
|
|
docker run --rm -v $PWD:/app -w /app --platform linux/arm/v7 ghcr.io/nonannet/armv7_test:1 \
|
|
bash -lc "pip install . && \
|
|
mkdir -p build/runner && \
|
|
gcc -O3 -DENABLE_LOGGING -o build/runner/coparun src/coparun/runmem.c \
|
|
src/coparun/coparun.c src/coparun/mem_man.c && \
|
|
pytest && \
|
|
bash tools/create_asm.sh"
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: runner-linux-armv7
|
|
path: build/runner/*
|
|
|
|
build-windows:
|
|
needs: [build_stencils]
|
|
runs-on: windows-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.10"]
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install Python dependencies
|
|
run: python -m pip install .[dev]
|
|
|
|
- name: Set up MSVC environment
|
|
uses: microsoft/setup-msbuild@v2
|
|
with:
|
|
vs-version: 'latest'
|
|
|
|
- name: Compile coparun
|
|
shell: cmd
|
|
run: |
|
|
mkdir build\runner
|
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64
|
|
cl /DENABLE_BASIC_LOGGING /Od src\coparun\runmem.c src\coparun\coparun.c src\coparun\mem_man.c /Fe:build\runner\coparun.exe
|
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x86
|
|
cl /DENABLE_BASIC_LOGGING /Od src\coparun\runmem.c src\coparun\coparun.c src\coparun\mem_man.c /Fe:build\runner\coparun-x86.exe
|
|
|
|
- name: Run tests with pytest
|
|
run: pytest
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
if: strategy.job-index == 0
|
|
with:
|
|
name: runner-win
|
|
path: build/runner/*
|
|
|
|
release-stencils:
|
|
needs: [build_stencils, build-ubuntu, build-windows, build-arm64, build-armv6, build-armv7]
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
fetch-tags: true
|
|
sparse-checkout: |
|
|
pyproject.toml
|
|
tools/get_tag.sh
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: tmp
|
|
|
|
- name: Get version tag name
|
|
id: version
|
|
run: bash tools/get_tag.sh
|
|
|
|
- name: Release stencils
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
set -v
|
|
mkdir -p release
|
|
cp tmp/stencil-object-files/* release/
|
|
cp tmp/musl-object-files/*.o release/
|
|
cp tmp/musl-object-files/COPYRIGHT release/MUSL-COPYRIGHT.txt
|
|
cp tmp/runner-linux-x86_64/coparun release/
|
|
cp tmp/runner-linux-arm64/coparun release/coparun-aarch64
|
|
cp tmp/runner-linux-armv6/coparun release/coparun-armv6
|
|
cp tmp/runner-linux-armv7/coparun release/coparun-armv7
|
|
cp tmp/runner-win/coparun*.exe release/
|
|
|
|
TAG="${{ steps.version.outputs.version }}"
|
|
|
|
if ! gh release view "$TAG" &>/dev/null; then
|
|
echo "Creating new stencil release $TAG"
|
|
gh release create "$TAG" release/* \
|
|
--prerelease \
|
|
--title "$TAG" \
|
|
--notes "Automated release stencil for $TAG"
|
|
else
|
|
echo "Updating existing release for $TAG"
|
|
gh release upload "$TAG" release/* --clobber
|
|
fi
|
|
|
|
build-docs:
|
|
needs: [build_stencils, build-ubuntu, build-windows, build-arm64, build-armv6, build-armv7]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-tags: true
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: stencil-object-files
|
|
path: src/copapy/obj
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: build/tmp
|
|
|
|
- uses: actions/setup-python@v3
|
|
with:
|
|
python-version: "3.x"
|
|
|
|
- name: Install package and dependencies
|
|
run: pip install .[doc_build]
|
|
|
|
- name: Build Docs
|
|
run: |
|
|
mkdir -p build/stencils
|
|
python stencils/generate_stencils.py build/stencils/stencils.c
|
|
cd docs
|
|
make html
|
|
touch build/html/.nojekyll
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: docs/build/html
|
|
|
|
deploy-docs:
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
needs: build-docs
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4 |