fixup! [#70236] Add windows tests to gh actions #66
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: test-systemc-examples | |
on: | |
pull_request: | |
push: | |
workflow_dispatch: | |
inputs: | |
renode_gitrev: | |
description: 'Renode git revision' | |
required: false | |
renode_gitrepo: | |
description: 'Renode git repository' | |
required: false | |
env: | |
WEST_VERSION: 1.2.0 | |
ZEPHYR_SDK_VERSION: 0.16.5-1 | |
ZEPHYR_SDK_BASENAME: zephyr-sdk-${ZEPHYR_SDK_VERSION} | |
ZEPHYR_SDK_FILENAME: zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz | |
ZEPHYR_VERSION: d0ae1a8b1057c0a8b510860d1cbdbb1cb79f2411 | |
jobs: | |
build-zephyr-binaries: | |
name: Build Zephyr Binaries | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
sudo apt-get -qqy update | |
sudo apt-get install -qqy wget python3-pip python3-venv cmake git ninja-build | |
- name: Set up Python virtual environment | |
run: | | |
python3 -m venv venv | |
source venv/bin/activate | |
echo "PATH=$PATH" >> "$GITHUB_ENV" | |
pip3 install west=="$WEST_VERSION" | |
- name: Set up Zephyr SDK | |
run: | | |
wget --no-verbose https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${{ env.ZEPHYR_SDK_VERSION }}/${{ env.ZEPHYR_SDK_FILENAME }} | |
tar xf ${{ env.ZEPHYR_SDK_FILENAME }} | |
pushd ${{ env.ZEPHYR_SDK_BASENAME }} | |
./setup.sh -t all -c | |
popd | |
echo "ZEPHYR_SDK_INSTALL_DIR=$(pwd)/${{ env.ZEPHYR_SDK_BASENAME }}" >> $GITHUB_ENV | |
- name: Get Zephyr source | |
run: | | |
west init zephyrproject | |
pushd zephyrproject/zephyr | |
git checkout ${{ env.ZEPHYR_VERSION }} | |
west update | |
echo "ZEPHYR_BASE=$PWD" >> "$GITHUB_ENV" | |
pip3 install -r scripts/requirements.txt | |
popd | |
- name: Build Zephyr examples | |
run: | | |
mkdir -p artifacts/zephyr_binaries | |
for i in `find examples -name "zephyr"`; do | |
EXAMPLE_NAME=`echo $i | sed -e "s/examples\///" | sed -e "s/\/zephyr//"` | |
mkdir -p examples/$EXAMPLE_NAME/bin | |
pushd zephyrproject/zephyr | |
west build -b stm32f401_mini ../../examples/$EXAMPLE_NAME/zephyr | |
cp build/zephyr/zephyr.elf ../../examples/$EXAMPLE_NAME/bin/$EXAMPLE_NAME.elf | |
cp build/zephyr/zephyr.elf ../../artifacts/zephyr_binaries/$EXAMPLE_NAME.elf | |
rm -rf build/ | |
popd | |
done | |
- name: Upload Zephyr binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: zephyr_binaries-${{ env.ZEPHYR_VERSION }}-${{ github.run_id }} | |
path: artifacts/zephyr_binaries | |
build-systemc: | |
name: Build SystemC | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get -qqy update | |
sudo apt-get -qqy upgrade && sudo apt-get install -qqy cmake clang git make autoconf mingw-w64 | |
- name: Fetch SystemC repo | |
run: | | |
git submodule update --init | |
- name: Build SystemC For Windows | |
run: | | |
mkdir -p artifacts/systemc_windows | |
pushd systemc | |
sed -i 's/# include <Windows\.h>/#include <windows.h>/g' src/sysc/kernel/sc_cmnhdr.h | |
mkdir -p build | |
pushd build | |
cmake .. -DCMAKE_SYSTEM_NAME=Windows \ | |
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc-posix \ | |
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++-posix \ | |
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ | |
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ | |
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ | |
-DMSVC=true \ | |
-DCMAKE_CXX_STANDARD=14 \ | |
-DCMAKE_THREAD_LIBS_INIT="-lpthread" \ | |
-DCMAKE_INSTALL_PREFIX=$(pwd)/../install | |
make -j | |
cp src/libsystemc.a ../../artifacts/systemc_windows/ | |
popd | |
popd | |
- name: Upload systemC for Windows | |
uses: actions/upload-artifact@v4 | |
with: | |
name: systemc_windows-${{ github.run_id }} | |
path: artifacts/systemc_windows | |
build-examples-linux: | |
name: Build Examples Linux | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get -qqy update | |
sudo apt-get install -qqy libsystemc libsystemc-dev clang cmake | |
- name: Download and build Renode | |
uses: antmicro/renode-test-action@v4 | |
with: | |
renode-repository: ${{ inputs.renode_gitrepo || 'https://github.com/renode/renode' }} | |
renode-revision: ${{ inputs.renode_gitrev || 'master' }} | |
- name: Build linux examples | |
run: | | |
mkdir -p artifacts/linux_example_binaries | |
mkdir -p artifacts/linux_test_binaries | |
mkdir -p build | |
pushd build | |
cmake .. -DCMAKE_CXX_STANDARD=14 | |
make | |
popd | |
for i in examples/*/; do | |
cp "$i"/bin/* artifacts/linux_example_binaries | |
rm -rf "$i"/bin | |
done | |
for i in tests/*/; do | |
cp "$i"/bin/* artifacts/linux_test_binaries | |
rm -rf "$i"/bin | |
done | |
rm -rf build | |
- name: Upload linux example binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux_example_binaries-${{ github.run_id }} | |
path: artifacts/linux_example_binaries | |
- name: Upload linux test binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux_test_binaries-${{ github.run_id }} | |
path: artifacts/linux_test_binaries | |
build-examples-windows: | |
name: Build Examples Windows | |
runs-on: windows-latest | |
needs: [build-zephyr-binaries, build-systemc] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup MSYS2 | |
uses: msys2/setup-msys2@v2 | |
with: | |
update: true | |
install: >- | |
git | |
mingw-w64-x86_64-cmake | |
mingw-w64-x86_64-gcc | |
mingw-w64-x86_64-make | |
patch | |
- name: Fetch SystemC repo | |
run: | | |
git submodule update --init | |
- name: Download systemC built for Windows | |
uses: actions/download-artifact@v4 | |
with: | |
name: systemc_windows-${{ github.run_id }} | |
path: artifacts/systemc_windows | |
- name: Download and build Renode | |
uses: antmicro/renode-test-action@v4 | |
with: | |
renode-repository: ${{ inputs.renode_gitrepo || 'https://github.com/renode/renode' }} | |
renode-revision: ${{ inputs.renode_gitrev || 'master' }} | |
- name: Build Windows examples | |
run: | | |
exec cmd //c "$RUNNER_TEMP/setup-msys2/msys2 $0" | |
mkdir -p artifacts/windows_example_binaries | |
mkdir -p artifacts/windows_test_binaries | |
mkdir -p build | |
pushd build | |
cmake .. -DCMAKE_SYSTEM_NAME=Windows \ | |
-DCMAKE_CXX_STANDARD=14 \ | |
-DUSER_SYSTEMC_INCLUDE_DIR=$(pwd)/../systemc/src \ | |
-DUSER_SYSTEMC_LIB_DIR=$(pwd)/../artifacts/systemc_windows | |
make | |
popd | |
for i in examples/*/; do | |
cp "$i"/bin/* artifacts/windows_example_binaries | |
rm -rf "$i"/bin | |
done | |
for i in tests/*/; do | |
cp "$i"/bin/* artifacts/windows_test_binaries | |
rm -rf "$i"/bin | |
done | |
rm -rf build | |
- name: Upload Windows example binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows_example_binaries-${{ github.run_id }} | |
path: artifacts/windows_example_binaries | |
- name: Upload Windows test binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows_test_binaries-${{ github.run_id }} | |
path: artifacts/windows_test_binaries | |
test-examples-linux: | |
uses: ./.github/workflows/test-examples.yml | |
needs: build-examples-linux | |
with: | |
runner: ubuntu-20.04 | |
example_binaries: linux_example_binaries | |
test_binaries: linux_example_binaries | |
test-examples-windows: | |
uses: ./.github/workflows/test-examples.yml | |
needs: build-examples-windows | |
with: | |
runner: windows-latest | |
example_binaries: windows_example_binaries | |
test_binaries: windows_example_binaries |