!2287 merge from r0.10 #300
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: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches-ignore: | |
- 'test' | |
pull_request: | |
env: | |
CMAKE_VERSION: 3.22.3 | |
OMP_NUM_THREADS: 1 | |
jobs: | |
standard: | |
if: ${{ true }} | |
strategy: | |
fail-fast: false | |
matrix: | |
runs-on: [ubuntu-latest] | |
python: | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- '3.10' | |
include: | |
- test_install: false | |
- test_bdist_wheel: false | |
- python: 3.9 | |
test_install: true | |
VENV_PYTHON_TEST_PKGS: | |
- python: 3.8 | |
test_bdist_wheel: true | |
name: "Python ${{ matrix.python }} • ${{ matrix.runs-on }} • x64" | |
runs-on: ${{ matrix.runs-on }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
if: env.ACT != 'true' | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*¨ | |
- name: Setup Python ${{ matrix.python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: 'pip' | |
- name: Prepare env | |
run: | | |
python3 -m pip install -U wheel build | |
sudo apt-get update && sudo apt-get install -y libboost-filesystem-dev --no-install-recommends | |
if [ ! "$(cat /etc/os-release | grep VERSION_ID | cut -d= -f2 | tr -d '"')" == "20.04" ]; then | |
sudo apt-get install -y glibc-tools --no-install-recommends | |
fi | |
- name: Setup CCache | |
uses: hendrikmuhs/ccache-action@v1.2.5 | |
with: | |
key: ${{ matrix.runs-on }}-python-${{ matrix.python }}-ccache | |
max-size: 75M | |
- name: Cache CMake installer | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
key: cmake-${{ env.CMAKE_VERSION }} | |
- name: Install latest CMake | |
run: | | |
if [ ! -e cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh ]; then | |
url_base='https://github.com/Kitware/CMake/releases/download' | |
wget ${url_base}/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
fi | |
sudo bash cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh --skip-license --prefix=/usr/local | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: >- | |
${{ matrix.runs-on }}-python-${{ matrix.python }}-python-venv | |
-${{ hashFiles('build_locally.sh', 'scripts/build/**.sh') }}-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: >- | |
${{ matrix.runs-on }}-python-${{ matrix.python }}-third-party-libs-${{ hashFiles('third_party/**') }} | |
-${{ secrets.cache_ver }} | |
- name: Configure | |
run: | | |
./build_locally.sh --debug-cmake --ccache --no-gitee --debug \ | |
--configure-only -c --clean-3rdparty --prefix="${{ github.workspace }}/install" \ | |
--cmake-no-registry \ | |
-- -DPython_FIND_UNVERSIONED_NAMES:STRING='FIRST' | |
- name: Build | |
run: ./build_locally.sh --debug-cmake --ccache | |
- name: Install | |
run: ./build_locally.sh --install # NB: no need to pass the other parameters | |
# ------------------------------------------------------------------------ | |
- name: Test (setup.py) installation | |
if: matrix.test_bdist_wheel | |
env: | |
VENV_PYTHON_TEST_PKGS: ${{ matrix.VENV_PYTHON_TEST_PKGS }} | |
run: | | |
./build.sh --debug-cmake \ | |
--fast-build --no-build-isolation --no-delocate --ccache --cmake-no-registry --no-gitee | |
- name: Test tests/st | |
run: | | |
pwd | |
source venv/bin/activate | |
export PYTHONPATH=`pwd`:$PYTHONPATH | |
which python | |
which python3 | |
which pip | |
echo $PYTHONPATH | |
pip install -r requirements_test.txt | |
pip install pytest | |
python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" | |
pytest tests/st -rs | |
# ============================================================================ | |
macos: | |
if: ${{ true }} | |
runs-on: macos-11 | |
name: "MacOS 11 • ${{ matrix.xcode }} • x64" | |
env: | |
DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer" | |
CC: /usr/bin/clang | |
CXX: /usr/bin/clang++ | |
strategy: | |
fail-fast: false | |
matrix: | |
xcode: | |
- "Xcode_11.7" # Not available on macos-12 | |
- "Xcode_12.4" # Not available on macos-12 | |
- "Xcode_12.5.1" # Not available on macos-12 | |
# - "Xcode_13.0" # Not available on macos-12 | |
- "Xcode_13.1" | |
- "Xcode_13.2.1" | |
# - "Xcode_13.3.1" # macos-12 only | |
# - "Xcode_13.4.1" # macos-12 only | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
if: env.ACT != 'true' | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*¨ | |
- name: Setup Python ${{ matrix.python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: 'pip' | |
- name: Prepare env | |
run: | | |
python3 -m pip install -U wheel build | |
brew install libomp ccache | |
- name: Setup CCache | |
uses: hendrikmuhs/ccache-action@v1.2.5 | |
with: | |
key: macos-${{ matrix.xcode }}-ccache | |
max-size: 75M | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: macos-python-venv-${{ hashFiles('build_locally.sh', 'scripts/build/**.sh') }}-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: macos-${{ matrix.xcode }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure | |
run: >- | |
./build_locally.sh --debug-cmake --ccache --only-pytest --no-gitee --debug | |
--configure-only -c --clean-3rdparty --prefix="${{ github.workspace }}/install" | |
--cmake-no-registry | |
- name: Build | |
run: ./build_locally.sh --debug-cmake --ccache | |
- name: Install | |
run: ./build_locally.sh --install # NB: no need to pass the other parameters | |
- name: Test tests/st | |
run: | | |
pwd | |
source venv/bin/activate | |
export PYTHONPATH=`pwd`:$PYTHONPATH | |
which python | |
which python3 | |
which pip | |
echo $PYTHONPATH | |
pip install -r requirements_test.txt | |
pip install pytest | |
python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" | |
pytest tests/st -rs | |
# ============================================================================ | |
gcc: | |
if: ${{ true }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
gcc: | |
- 7 # C++17 earliest version | |
- 8 | |
- 9 | |
- 10 | |
- 11 | |
- 12 | |
name: "GCC ${{ matrix.gcc }} • x64" | |
container: "gcc:${{ matrix.gcc }}" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git config --global --add safe.directory /__w/mindquantum/mindquantum | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Prepare env | |
run: > | |
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel python3-venv | |
libboost-filesystem-dev gdb --no-install-recommends | |
- name: Setup CCache | |
uses: hendrikmuhs/ccache-action@v1.2.5 | |
with: | |
key: gcc-${{ matrix.gcc }}-ccache | |
max-size: 75M | |
- name: Cache CMake installer | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
key: cmake-${{ env.CMAKE_VERSION }} | |
- name: Install latest CMake | |
run: | | |
if [ ! -e cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh ]; then | |
url_base='https://github.com/Kitware/CMake/releases/download' | |
wget ${url_base}/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
fi | |
bash cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh --skip-license --prefix=/usr/local | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: >- | |
gcc-${{ matrix.gcc }}-python-venv-${{ hashFiles('build_locally.sh', 'scripts/build/**.sh') }} | |
-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: gcc-${{ matrix.gcc }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure | |
run: >- | |
./build_locally.sh --debug-cmake --ccache --only-pytest --no-gitee --debug | |
--configure-only -c --logging --clean-3rdparty --prefix="${{ github.workspace }}/install" | |
--cmake-no-registry -- -DENABLE_STACK_PROTECTION=ON | |
- name: Build | |
run: ./build_locally.sh --debug-cmake --ccache | |
- name: Install | |
run: ./build_locally.sh --install # NB: no need to pass the other parameters | |
- name: Run debugger in case of failure | |
if: ${{ failure() }} | |
run: | | |
cd build | |
ctest --output-on-failure > ctest_output.txt || true | |
sed -e '1,/The following tests FAILED:/ d' ctest_output.txt \ | |
| cut -d '-' -f2 \ | |
| sed -e 's/ (SEGFAULT)//' -e 's/ *$//g' -e 's/^ *//g' > failed_tests.txt | |
ctest -V -N \ | |
| grep 'Test command' \ | |
| cut -d ':' -f3 \ | |
| sed -e 's/ *$//g' -e 's/^ *//g' > test_commands.txt | |
while read name; do | |
echo "Processing $name" | |
cmd=$(grep "$name" test_commands.txt) | |
if [ -z "$cmd" ]; then | |
echo " -> skipping because cannot find command in command list!" | |
continue | |
fi | |
# lines are of the form /path/to/test/executable "Some Filter" | |
program=$(echo "$cmd" \ | |
| cut -d'"' -f1\ | |
| sed -e 's/ *$//g' -e 's/^ *//g') | |
args=$(echo "$cmd" \ | |
| sed -e "s|$program||" -e 's/ *$//g' -e 's/^ *//g') | |
if [ -z "$program" ]; then | |
echo " -> skipping because cannot extract program from command line!" | |
continue | |
elif [ ! -x "$program" ]; then | |
echo " -> skipping because program is not an executable! ($program)" | |
continue | |
fi | |
gdb --batch -ex 'run' -ex 'thread apply all bt' -ex 'quit' --args "$program" "$args" | |
# lldb --batch -o "file $program" -o "run $args" -k 'bt all' -o 'quit' | |
done < failed_tests.txt | |
- name: Save tests executable in case of failure | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-executables-gcc-${{ matrix.gcc }} | |
retention-days: 5 | |
path: | | |
build/tests | |
!build/tests/**/Makefile | |
!build/tests/**/*.* | |
- name: Test tests/st | |
shell: bash | |
run: | | |
pwd | |
source venv/bin/activate | |
export PYTHONPATH=`pwd`:$PYTHONPATH | |
which python | |
which python3 | |
which pip | |
echo $PYTHONPATH | |
pip install -r requirements_test.txt | |
pip install pytest | |
python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" | |
pytest tests/st -rs | |
# ============================================================================ | |
clang: | |
if: ${{ true }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
clang: | |
- 7 | |
- 8 | |
- 9 | |
- 10 # first version for full C++17 support (with patches) | |
- 11 | |
- 12 | |
- 13 | |
- 14 | |
env: | |
CC: clang | |
CXX: clang++ | |
name: "Clang ${{ matrix.clang }} • x64" | |
container: "silkeh/clang:${{ matrix.clang }}" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: install git | |
run: | | |
apt-get update && apt-get install -y git | |
- name: install libomp-${{ matrix.clang }}-dev | |
run: | | |
apt-get update && apt-get install -y libomp-${{ matrix.clang }}-dev | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
ls -alth | |
# pwd | |
# git config --global --add safe.directory /__w/mindquantum/mindquantum | |
# git fetch --prune --unshallow | |
# git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Prepare env | |
run: > | |
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel python3-venv | |
gdb --no-install-recommends | |
- name: Setup CCache | |
uses: hendrikmuhs/ccache-action@v1.2.5 | |
with: | |
key: clang-${{ matrix.clang }}-ccache | |
max-size: 75M | |
- name: Cache CMake installer | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
key: cmake-${{ env.CMAKE_VERSION }} | |
- name: Install latest CMake | |
run: | | |
if [ ! -e cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh ]; then | |
url_base='https://github.com/Kitware/CMake/releases/download' | |
wget ${url_base}/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
fi | |
bash cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh --skip-license --prefix=/usr/local | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: >- | |
clang-${{ matrix.clang }}-python-venv-${{ hashFiles('build_locally.sh', 'scripts/build/**.sh') }} | |
-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: clang-${{ matrix.clang }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure (Clang) | |
if: matrix.clang != '8' | |
run: >- | |
./build_locally.sh --debug-cmake --ccache --only-pytest --no-gitee --debug | |
--configure-only -c --clean-3rdparty --prefix="${{ github.workspace }}/install" | |
--cmake-no-registry -- -DENABLE_STACK_PROTECTION=ON | |
# Due to compiler segmentation fault with Clang 8 in debug mode | |
- name: Configure (Clang 8) | |
if: matrix.clang == '8' | |
run: >- | |
./build_locally.sh --debug-cmake --ccache --only-pytest --no-gitee | |
--configure-only -c --clean-3rdparty --prefix="${{ github.workspace }}/install" | |
--cmake-no-registry -- -DENABLE_STACK_PROTECTION=ON | |
- name: Build | |
run: ./build_locally.sh --debug-cmake --ccache | |
- name: Install | |
run: ./build_locally.sh --install # NB: no need to pass the other parameters | |
- name: Run debugger in case of failure | |
if: ${{ failure() }} | |
run: | | |
cd build | |
ctest --output-on-failure > ctest_output.txt || true | |
sed -e '1,/The following tests FAILED:/ d' ctest_output.txt \ | |
| cut -d '-' -f2 \ | |
| sed -e 's/ (SEGFAULT)//' -e 's/ *$//g' -e 's/^ *//g' > failed_tests.txt | |
ctest -V -N \ | |
| grep 'Test command' \ | |
| cut -d ':' -f3 \ | |
| sed -e 's/ *$//g' -e 's/^ *//g' > test_commands.txt | |
while read name; do | |
echo "Processing $name" | |
cmd=$(grep "$name" test_commands.txt) | |
if [ -z "$cmd" ]; then | |
echo " -> skipping because cannot find command in command list!" | |
continue | |
fi | |
# lines are of the form /path/to/test/executable "Some Filter" | |
program=$(echo "$cmd" \ | |
| cut -d'"' -f1\ | |
| sed -e 's/ *$//g' -e 's/^ *//g') | |
args=$(echo "$cmd" \ | |
| sed -e "s|$program||" -e 's/ *$//g' -e 's/^ *//g') | |
if [ -z "$program" ]; then | |
echo " -> skipping because cannot extract program from command line!" | |
continue | |
fi | |
gdb --batch -ex 'run' -ex 'thread apply all bt' -ex 'quit' --args "$program" "$args" | |
# lldb --batch -o "file $program" -o "run $args" -k 'bt all' -o 'quit' | |
done < failed_tests.txt | |
- name: Save tests executable in case of failure | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-executables-clang-${{ matrix.clang }} | |
retention-days: 5 | |
path: | | |
build/tests | |
!build/tests/**/Makefile | |
!build/tests/**/*.* | |
- name: Test tests/st | |
shell: bash | |
run: | | |
pwd | |
source venv/bin/activate | |
export PYTHONPATH=`pwd`:$PYTHONPATH | |
which python | |
which python3 | |
which pip | |
echo $PYTHONPATH | |
pip install -r requirements_test.txt | |
pip install pytest | |
python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" | |
pytest tests/st -rs | |
# ============================================================================ | |
msvc: | |
if: ${{ true }} | |
runs-on: windows-latest | |
name: "MSVC • x64" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Enable Developer Command Prompt | |
uses: ilammy/msvc-dev-cmd@v1.12.0 | |
- name: Install Scoop && Scoop packages | |
run: | | |
iwr -useb get.scoop.sh -outfile 'install.ps1' | |
.\install.ps1 -RunAsAdmin | |
Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH | |
scoop install ccache | |
- name: Get Date | |
id: get-date | |
shell: bash | |
run: echo "date=$(date -Iseconds)" >> $GITHUB_OUTPUT | |
- name: Restore cache for CCache | |
if: env.ACT != 'true' | |
id: ccache-cache | |
uses: martijnhols/actions-cache/restore@v3.0.11b | |
with: | |
path: ccache | |
key: msvc-ccache-${{ steps.get-date.outputs.date }} | |
restore-keys: msvc-ccache- | |
- name: Configure CCache | |
run: | | |
ccache --set-config=cache_dir="$PWD/ccache" | |
ccache --set-config=max_size=250M | |
ccache --set-config=compression=true | |
ccache -pz | |
ccache -sv | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: msvc-python-venv-${{ hashFiles('build_locally.ps1', 'scripts/build/**.ps1') }}-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: msvc-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure | |
env: | |
CC: cl | |
CXX: cl | |
run: >- | |
./build_locally.ps1 -DebugCmake -Ninja -CCache -OnlyPytest -NoGitee | |
-ConfigureOnly -C -Clean3rdParty -Prefix "${{ github.workspace }}/install" | |
-CMakeNoRegistry | |
-DUSE_PARALLEL_STL=OFF | |
- name: Build | |
run: ./build_locally.ps1 -DebugCmake -Ninja -CCache | |
- name: Install | |
run: ./build_locally.ps1 -Install | |
- name: Print CCache statistics | |
run: | | |
ccache -sv | |
- name: Save cache for CCache | |
if: env.ACT != 'true' | |
uses: martijnhols/actions-cache/save@v3.0.11b | |
with: | |
path: ccache | |
key: msvc-ccache-${{ steps.get-date.outputs.date }} | |
# ============================================================================ | |
clang-cl: | |
if: ${{ true }} | |
runs-on: windows-latest | |
name: "Clang-Cl • x64" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Enable Developer Command Prompt | |
uses: ilammy/msvc-dev-cmd@v1.12.0 | |
- name: Install Scoop && Scoop packages | |
run: | | |
iwr -useb get.scoop.sh -outfile 'install.ps1' | |
.\install.ps1 -RunAsAdmin | |
Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH | |
scoop install ccache | |
- name: Get Date | |
id: get-date | |
shell: bash | |
run: echo "date=$(date -Iseconds)" >> $GITHUB_OUTPUT | |
- name: Restore cache for CCache | |
if: env.ACT != 'true' | |
id: ccache-cache | |
uses: martijnhols/actions-cache/restore@v3.0.11b | |
with: | |
path: ccache | |
key: clang-cl-ccache-${{ steps.get-date.outputs.date }} | |
restore-keys: clang-cl-ccache- | |
- name: Configure CCache | |
run: | | |
ccache --set-config=cache_dir="$PWD/ccache" | |
ccache --set-config=max_size=70M | |
ccache --set-config=compression=true | |
ccache -pz | |
ccache -sv | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: > | |
clang-cl-python-venv-${{ hashFiles('build_locally.ps1', 'scripts/build/**.ps1') }}-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: clang-cl-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure | |
env: | |
CC: clang-cl | |
CXX: clang-cl | |
run: >- | |
./build_locally.ps1 -DebugCmake -Ninja -CCache -OnlyPytest -NoGitee | |
-ConfigureOnly -C -Clean3rdParty -Prefix "${{ github.workspace }}/install" | |
-CMakeNoRegistry -Verbose | |
-DUSE_PARALLEL_STL=OFF | |
- name: Build | |
run: ./build_locally.ps1 -DebugCmake -Ninja -CCache -Verbose | |
- name: Install | |
run: ./build_locally.ps1 -Install | |
- name: Print CCache statistics | |
run: | | |
ccache -sv | |
- name: Save cache for CCache | |
if: env.ACT != 'true' | |
uses: martijnhols/actions-cache/save@v3.0.11b | |
with: | |
path: ccache | |
key: clang-cl-ccache-${{ steps.get-date.outputs.date }} | |
# ============================================================================ | |
mingw64: | |
if: ${{ true }} | |
runs-on: windows-2022 | |
strategy: | |
fail-fast: false | |
name: "MINGW64 • x64" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
# - name: Setup CCache | |
# uses: hendrikmuhs/ccache-action@v1.2.5 | |
# with: | |
# key: mingw64-ccache | |
# max-size: 75M | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: >- | |
mingw64-python-venv-${{ hashFiles('build_locally.ps1', 'scripts/build/**.ps1') }}-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: mingw64-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Set up MinGW64 | |
uses: egor-tensin/setup-mingw@v2 | |
id: mingw64-setup | |
continue-on-error: true | |
with: | |
platform: x64 | |
- name: Setup CC and CXX | |
if: steps.mingw64-setup.outcome == 'success' | |
env: | |
CC: ${{ steps.mingw64-setup.outputs.gcc }} | |
CXX: ${{ steps.mingw64-setup.outputs.gxx }} | |
run: | | |
"CC='$Env:CC'" >> $Env:GITHUB_ENV | |
"CXX='$Env:CXX'" >> $Env:GITHUB_ENV | |
- name: Set up MinGW64 (2nd try) | |
uses: egor-tensin/setup-mingw@v2 | |
if: steps.mingw64-setup.outcome == 'failure' | |
id: mingw64-setup-2 | |
continue-on-error: false | |
with: | |
platform: x64 | |
- name: Setup CC and CXX | |
if: steps.mingw64-setup-2.outcome == 'success' | |
env: | |
CC: ${{ steps.mingw64-setup-2.outputs.gcc }} | |
CXX: ${{ steps.mingw64-setup-2.outputs.gxx }} | |
run: | | |
"CC='$Env:CC'" >> $Env:GITHUB_ENV | |
"CXX='$Env:CXX'" >> $Env:GITHUB_ENV | |
- name: Configure | |
run: >- | |
./build_locally.ps1 -DebugCmake -Ninja -OnlyPytest -NoGitee | |
-ConfigureOnly -C -Clean3rdParty -Prefix "${{ github.workspace }}/install" | |
-CMakeNoRegistry | |
--% -G "MinGW Makefiles" -DUSE_PARALLEL_STL=OFF | |
- name: Build | |
run: ./build_locally.ps1 -DebugCmake -Ninja | |
- name: Install | |
run: ./build_locally.ps1 -Install | |
# ============================================================================ | |
msys2: | |
if: ${{ true }} | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- msystem: MINGW64 | |
installdeps: >- | |
git | |
patch | |
make | |
mingw-w64-x86_64-toolchain | |
mingw-w64-x86_64-cmake | |
mingw-w64-x86_64-ccache | |
mingw-w64-x86_64-gmp | |
mingw-w64-x86_64-boost | |
mingw-w64-x86_64-python | |
mingw-w64-x86_64-python-pip | |
CC: gcc | |
CXX: g++ | |
- msystem: CLANG64 | |
installdeps: >- | |
git | |
patch | |
make | |
mingw-w64-clang-x86_64-toolchain | |
mingw-w64-clang-x86_64-cmake | |
mingw-w64-clang-x86_64-ccache | |
mingw-w64-clang-x86_64-gmp | |
mingw-w64-clang-x86_64-boost | |
mingw-w64-clang-x86_64-python | |
mingw-w64-clang-x86_64-python-pip | |
CC: clang | |
CXX: clang++ | |
- msystem: UCRT64 | |
installdeps: >- | |
git | |
patch | |
make | |
mingw-w64-ucrt-x86_64-toolchain | |
mingw-w64-ucrt-x86_64-cmake | |
mingw-w64-ucrt-x86_64-ccache | |
mingw-w64-ucrt-x86_64-gmp | |
mingw-w64-ucrt-x86_64-boost | |
mingw-w64-ucrt-x86_64-python | |
mingw-w64-ucrt-x86_64-python-pip | |
CC: gcc | |
CXX: g++ | |
name: "MSYS2 ${{ matrix.msystem }} • x64" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Setup MSYS | |
uses: msys2/setup-msys2@v2 | |
with: | |
install: ${{ matrix.installdeps }} | |
msystem: ${{ matrix.msystem }} | |
path-type: strict | |
update: false | |
- name: Get Date | |
id: get-date | |
shell: msys2 {0} | |
run: echo "date=$(date -Iseconds)" >> $GITHUB_OUTPUT | |
- name: Restore cache for CCache | |
if: env.ACT != 'true' && matrix.msystem != 'MSYS' | |
id: ccache-cache | |
uses: martijnhols/actions-cache/restore@v3.0.11b | |
with: | |
path: ccache | |
key: msys2-${{ matrix.msystem }}-ccache-${{ steps.get-date.outputs.date }} | |
restore-keys: msys2-${{ matrix.msystem }}-ccache- | |
- name: Configure CCache | |
shell: msys2 {0} | |
run: | | |
which ccache | |
ccache --help | |
ccache --set-config=cache_dir="$PWD/ccache" | |
ccache --set-config=max_size=75M | |
ccache --set-config=compression=true | |
ccache -pz | |
ccache -sv | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: >- | |
msys2-${{ matrix.msystem }}-python-venv-${{ hashFiles('build_locally.sh', 'scripts/build/**.sh') }} | |
-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: msys2-${{ matrix.msystem }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure | |
shell: msys2 {0} | |
env: | |
CC: ${{ matrix.CC }} | |
CXX: ${{ matrix.CXX }} | |
run: >- | |
./build_locally.sh --debug-cmake --ccache -v --only-pytest --no-gitee | |
--configure-only -c --clean-3rdparty --prefix="$PWD/install" | |
--cmake-no-registry | |
-- -G "MSYS Makefiles" | |
- name: Build | |
shell: msys2 {0} | |
env: | |
CC: ${{ matrix.CC }} | |
CXX: ${{ matrix.CXX }} | |
run: ./build_locally.sh --debug-cmake --ccache | |
- name: Install | |
shell: msys2 {0} | |
env: | |
CC: ${{ matrix.CC }} | |
CXX: ${{ matrix.CXX }} | |
run: ./build_locally.sh --install | |
- name: Print CCache statistics | |
shell: msys2 {0} | |
run: | | |
ccache -sv | |
- name: Save cache for CCache | |
if: env.ACT != 'true' | |
uses: martijnhols/actions-cache/save@v3.0.11b | |
with: | |
path: ccache | |
key: msys2-${{ matrix.msystem }}-ccache-${{ steps.get-date.outputs.date }} | |
# ============================================================================ | |
cuda: | |
if: ${{ true }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
cuda: | |
- 11.0.3-devel-ubuntu20.04 | |
- 11.1.1-devel-ubuntu20.04 | |
- 11.8.0-devel-ubuntu22.04 | |
name: "CUDA ${{ matrix.cuda }} • x64" | |
container: "nvidia/cuda:${{ matrix.cuda }}" | |
steps: | |
- name: Install and setup Git | |
run: | | |
apt-get update && apt-get upgrade -y | |
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata | |
apt-get install -y software-properties-common | |
add-apt-repository -y ppa:git-core/ppa | |
apt-get update && apt-get install -y git | |
git config --global --add safe.directory $PWD | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Install Python | |
run: >- | |
apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel | |
python3-venv --no-install-recommends | |
- name: Prepare env | |
run: >- | |
apt-get install -y autoconf automake binutils coreutils m4 gawk libtool gettext wget curl | |
--no-install-recommends | |
- name: Setup CCache | |
uses: hendrikmuhs/ccache-action@v1.2.5 | |
with: | |
key: cuda-${{ matrix.cuda }}-ccache | |
max-size: 75M | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: >- | |
cuda-${{ matrix.cuda }}-python-venv-${{ hashFiles('build_locally.sh', 'scripts/build/**.sh') }} | |
-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: cuda-${{ matrix.cuda }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure | |
run: >- | |
./build_locally.sh --debug-cmake --gpu --ccache --only-pytest --no-gitee | |
--configure-only -c --clean-3rdparty --prefix="${{ github.workspace }}/install" | |
--cmake-no-registry | |
- name: Build | |
run: ./build_locally.sh --debug-cmake --gpu --ccache | |
- name: Install | |
run: ./build_locally.sh --install | |
- name: Test tests/st | |
shell: bash | |
run: | | |
pwd | |
source venv/bin/activate | |
export PYTHONPATH=`pwd`:$PYTHONPATH | |
which python | |
which python3 | |
which pip | |
echo $PYTHONPATH | |
pip install -r requirements_test.txt | |
pip install pytest | |
python3 -c "import mindquantum as mq;print(mq.qft(range(3)))" | |
pytest tests/st -rs | |
# ============================================================================ | |
nvhpc: | |
if: ${{ true }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
nvhpc: | |
- 21.5-devel-cuda11.3 | |
- 22.3-devel-cuda11.6 | |
env: | |
CC: gcc | |
CXX: g++ | |
name: "NVHPC ${{ matrix.nvhpc }} • x64" | |
container: "nvcr.io/nvidia/nvhpc:${{ matrix.nvhpc }}-ubuntu20.04" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get history and tags for SCM versioning to work | |
run: | | |
git fetch --prune --unshallow | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Prepare env | |
run: > | |
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel python3-venv | |
libboost-filesystem-dev --no-install-recommends | |
- name: Setup CCache | |
uses: hendrikmuhs/ccache-action@v1.2.5 | |
with: | |
key: nvhpc-${{ matrix.nvhpc }}-ccache | |
max-size: 75M | |
- name: Cache CMake installer | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
key: cmake-${{ env.CMAKE_VERSION }} | |
- name: Install latest CMake | |
run: | | |
if [ ! -e cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh ]; then | |
url_base='https://github.com/Kitware/CMake/releases/download' | |
wget ${url_base}/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh | |
fi | |
bash cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh --skip-license --prefix=/usr/local | |
- name: Cache Python virtualenv | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: venv | |
key: >- | |
nvhpc-${{ matrix.nvhpc }}-python-venv-${{ hashFiles('build_locally.sh', 'scripts/build/**.sh') }} | |
-${{ secrets.cache_ver }} | |
- name: Cache compiled third-party libraries | |
if: env.ACT != 'true' | |
uses: actions/cache@v3 | |
with: | |
path: build/.mqlibs | |
key: nvhpc-${{ matrix.nvhpc }}-third-party-libs-${{ hashFiles('third_party/**') }}-${{ secrets.cache_ver }} | |
- name: Configure | |
run: >- | |
./build_locally.sh --debug-cmake --gpu --ccache --only-pytest --no-gitee | |
--configure-only -c --clean-3rdparty --prefix="${{ github.workspace }}/install" | |
--cmake-no-registry | |
- name: Build | |
run: ./build_locally.sh --debug-cmake --gpu --ccache | |
- name: Install | |
run: ./build_locally.sh --install |