|
| 1 | +# Copyright (c) 2023 The Bitcoin Core developers |
| 2 | +# Distributed under the MIT software license, see the accompanying |
| 3 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 4 | + |
| 5 | +name: CI |
| 6 | +on: |
| 7 | + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request. |
| 8 | + pull_request: |
| 9 | + # See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push. |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - '**' |
| 13 | + tags-ignore: |
| 14 | + - '**' |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.event_name != 'pull_request' && github.run_id || github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +env: |
| 21 | + DANGER_RUN_CI_ON_HOST: 1 |
| 22 | + CI_FAILFAST_TEST_LEAVE_DANGLING: 1 # GHA does not care about dangling processes and setting this variable avoids killing the CI script itself on error |
| 23 | + MAKEJOBS: '-j10' |
| 24 | + |
| 25 | +jobs: |
| 26 | + test-each-commit: |
| 27 | + name: 'test each commit' |
| 28 | + runs-on: ubuntu-22.04 |
| 29 | + if: github.event_name == 'pull_request' && github.event.pull_request.commits != 1 |
| 30 | + timeout-minutes: 360 # Use maximum time, see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes. Assuming a worst case time of 1 hour per commit, this leads to a --max-count=6 below. |
| 31 | + env: |
| 32 | + MAX_COUNT: 6 |
| 33 | + steps: |
| 34 | + - name: Determine fetch depth |
| 35 | + run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV" |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + ref: ${{ github.event.pull_request.head.sha }} |
| 39 | + fetch-depth: ${{ env.FETCH_DEPTH }} |
| 40 | + - name: Determine commit range |
| 41 | + run: | |
| 42 | + # Checkout HEAD~ and find the test base commit |
| 43 | + # Checkout HEAD~ because it would be wasteful to rerun tests on the PR |
| 44 | + # head commit that are already run by other jobs. |
| 45 | + git checkout HEAD~ |
| 46 | + # Figure out test base commit by listing ancestors of HEAD, excluding |
| 47 | + # ancestors of the most recent merge commit, limiting the list to the |
| 48 | + # newest MAX_COUNT ancestors, ordering it from oldest to newest, and |
| 49 | + # taking the first one. |
| 50 | + # |
| 51 | + # If the branch contains up to MAX_COUNT ancestor commits after the |
| 52 | + # most recent merge commit, all of those commits will be tested. If it |
| 53 | + # contains more, only the most recent MAX_COUNT commits will be |
| 54 | + # tested. |
| 55 | + # |
| 56 | + # In the command below, the ^@ suffix is used to refer to all parents |
| 57 | + # of the merge commit as described in: |
| 58 | + # https://git-scm.com/docs/git-rev-parse#_other_rev_parent_shorthand_notations |
| 59 | + # and the ^ prefix is used to exclude these parents and all their |
| 60 | + # ancestors from the rev-list output as described in: |
| 61 | + # https://git-scm.com/docs/git-rev-list |
| 62 | + echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD ^$(git rev-list -n1 --merges HEAD)^@ | head -1)" >> "$GITHUB_ENV" |
| 63 | + - run: | |
| 64 | + sudo apt-get update |
| 65 | + sudo apt-get install clang-15 ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y |
| 66 | + - name: Compile and run tests |
| 67 | + run: | |
| 68 | + # Run tests on commits after the last merge commit and before the PR head commit |
| 69 | + # Use clang++, because it is a bit faster and uses less memory than g++ |
| 70 | + git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && ./autogen.sh && CC=clang-15 CXX=clang++-15 ./configure && make clean && make -j $(nproc) check && ./test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }} |
| 71 | +
|
| 72 | + macos-native-arm64: |
| 73 | + name: 'macOS 14 native, arm64, no depends, sqlite only, gui' |
| 74 | + # Use latest image, but hardcode version to avoid silent upgrades (and breaks). |
| 75 | + # See: https://github.com/actions/runner-images#available-images. |
| 76 | + runs-on: macos-14 |
| 77 | + |
| 78 | + # No need to run on the read-only mirror, unless it is a PR. |
| 79 | + if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' |
| 80 | + |
| 81 | + timeout-minutes: 120 |
| 82 | + |
| 83 | + env: |
| 84 | + FILE_ENV: './ci/test/00_setup_env_mac_native.sh' |
| 85 | + BASE_ROOT_DIR: ${{ github.workspace }} |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: Checkout |
| 89 | + uses: actions/checkout@v4 |
| 90 | + |
| 91 | + - name: Clang version |
| 92 | + run: | |
| 93 | + sudo xcode-select --switch /Applications/Xcode_15.0.app |
| 94 | + clang --version |
| 95 | +
|
| 96 | + - name: Install Homebrew packages |
| 97 | + env: |
| 98 | + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 |
| 99 | + run: brew install automake libtool pkg-config gnu-getopt ccache boost libevent miniupnpc libnatpmp zeromq qt@5 qrencode |
| 100 | + |
| 101 | + # ELEMENTS |
| 102 | + - name: Override boost@1.85 |
| 103 | + run: | |
| 104 | + brew install boost@1.85 |
| 105 | + brew link --force --overwrite boost@1.85 |
| 106 | + echo "LDFLAGS=-L/opt/homebrew/opt/boost@1.85/lib" >> "$GITHUB_ENV" |
| 107 | + echo "CPPFLAGS=-I/opt/homebrew/opt/boost@1.85/include" >> "$GITHUB_ENV" |
| 108 | +
|
| 109 | + - name: Set Ccache directory |
| 110 | + run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV" |
| 111 | + |
| 112 | + - name: Restore Ccache cache |
| 113 | + id: ccache-cache |
| 114 | + uses: actions/cache/restore@v4 |
| 115 | + with: |
| 116 | + path: ${{ env.CCACHE_DIR }} |
| 117 | + key: ${{ github.job }}-ccache-${{ github.run_id }} |
| 118 | + restore-keys: ${{ github.job }}-ccache- |
| 119 | + |
| 120 | + - name: CI script |
| 121 | + run: ./ci/test_run_all.sh |
| 122 | + |
| 123 | + - name: Save Ccache cache |
| 124 | + uses: actions/cache/save@v4 |
| 125 | + if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' |
| 126 | + with: |
| 127 | + path: ${{ env.CCACHE_DIR }} |
| 128 | + # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache |
| 129 | + key: ${{ github.job }}-ccache-${{ github.run_id }} |
| 130 | + |
| 131 | + win64-native: |
| 132 | + name: 'Win64 native, VS 2022' |
| 133 | + # Use latest image, but hardcode version to avoid silent upgrades (and breaks). |
| 134 | + # See: https://github.com/actions/runner-images#available-images. |
| 135 | + runs-on: windows-2022 |
| 136 | + |
| 137 | + # No need to run on the read-only mirror, unless it is a PR. |
| 138 | + if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request' |
| 139 | + |
| 140 | + env: |
| 141 | + CCACHE_MAXSIZE: '200M' |
| 142 | + CI_CCACHE_VERSION: '4.7.5' |
| 143 | + CI_QT_CONF: '-release -silent -opensource -confirm-license -opengl desktop -static -static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -nomake examples -nomake tests -nomake tools -no-angle -no-dbus -no-gif -no-gtk -no-ico -no-icu -no-libjpeg -no-libudev -no-sql-sqlite -no-sql-odbc -no-sqlite -no-vulkan -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip doc -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtlottie -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -no-openssl -no-feature-bearermanagement -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-sql -no-feature-sqlmodel -no-feature-textbrowser -no-feature-textmarkdownwriter -no-feature-textodfwriter -no-feature-xml' |
| 144 | + CI_QT_DIR: 'qt-everywhere-src-5.15.11' |
| 145 | + CI_QT_URL: 'https://download.qt.io/archive/qt/5.15/5.15.11/single/qt-everywhere-opensource-src-5.15.11.zip' |
| 146 | + PYTHONUTF8: 1 |
| 147 | + TEST_RUNNER_TIMEOUT_FACTOR: 40 |
| 148 | + |
| 149 | + steps: |
| 150 | + - name: Checkout |
| 151 | + uses: actions/checkout@v4 |
| 152 | + |
| 153 | + - name: Configure Developer Command Prompt for Microsoft Visual C++ |
| 154 | + # Using microsoft/setup-msbuild is not enough. |
| 155 | + uses: ilammy/msvc-dev-cmd@v1 |
| 156 | + with: |
| 157 | + arch: x64 |
| 158 | + |
| 159 | + - name: Get tool information |
| 160 | + run: | |
| 161 | + msbuild -version | Out-File -FilePath "$env:GITHUB_WORKSPACE\msbuild_version" |
| 162 | + Get-Content -Path "$env:GITHUB_WORKSPACE\msbuild_version" |
| 163 | + $env:VCToolsVersion | Out-File -FilePath "$env:GITHUB_WORKSPACE\toolset_version" |
| 164 | + Write-Host "VCToolsVersion $(Get-Content -Path "$env:GITHUB_WORKSPACE\toolset_version")" |
| 165 | + $env:CI_QT_URL | Out-File -FilePath "$env:GITHUB_WORKSPACE\qt_url" |
| 166 | + $env:CI_QT_CONF | Out-File -FilePath "$env:GITHUB_WORKSPACE\qt_conf" |
| 167 | + py -3 --version |
| 168 | +
|
| 169 | + - name: Restore static Qt cache |
| 170 | + id: static-qt-cache |
| 171 | + uses: actions/cache/restore@v4 |
| 172 | + with: |
| 173 | + path: C:\Qt_static |
| 174 | + key: ${{ github.job }}-static-qt-${{ hashFiles('msbuild_version', 'qt_url', 'qt_conf') }} |
| 175 | + |
| 176 | + - name: Build static Qt. Download |
| 177 | + if: steps.static-qt-cache.outputs.cache-hit != 'true' |
| 178 | + shell: cmd |
| 179 | + run: | |
| 180 | + curl --location --output C:\qt-src.zip %CI_QT_URL% |
| 181 | + choco install --yes --no-progress jom |
| 182 | +
|
| 183 | + - name: Build static Qt. Expand source archive |
| 184 | + if: steps.static-qt-cache.outputs.cache-hit != 'true' |
| 185 | + shell: cmd |
| 186 | + run: tar -xf C:\qt-src.zip -C C:\ |
| 187 | + |
| 188 | + - name: Build static Qt. Create build directory |
| 189 | + if: steps.static-qt-cache.outputs.cache-hit != 'true' |
| 190 | + run: | |
| 191 | + Rename-Item -Path "C:\$env:CI_QT_DIR" -NewName "C:\qt-src" |
| 192 | + New-Item -ItemType Directory -Path "C:\qt-src\build" |
| 193 | +
|
| 194 | + - name: Build static Qt. Configure |
| 195 | + if: steps.static-qt-cache.outputs.cache-hit != 'true' |
| 196 | + working-directory: C:\qt-src\build |
| 197 | + shell: cmd |
| 198 | + run: ..\configure %CI_QT_CONF% -prefix C:\Qt_static |
| 199 | + |
| 200 | + - name: Build static Qt. Build |
| 201 | + if: steps.static-qt-cache.outputs.cache-hit != 'true' |
| 202 | + working-directory: C:\qt-src\build |
| 203 | + shell: cmd |
| 204 | + run: jom |
| 205 | + |
| 206 | + - name: Build static Qt. Install |
| 207 | + if: steps.static-qt-cache.outputs.cache-hit != 'true' |
| 208 | + working-directory: C:\qt-src\build |
| 209 | + shell: cmd |
| 210 | + run: jom install |
| 211 | + |
| 212 | + - name: Save static Qt cache |
| 213 | + if: steps.static-qt-cache.outputs.cache-hit != 'true' |
| 214 | + uses: actions/cache/save@v4 |
| 215 | + with: |
| 216 | + path: C:\Qt_static |
| 217 | + key: ${{ github.job }}-static-qt-${{ hashFiles('msbuild_version', 'qt_url', 'qt_conf') }} |
| 218 | + |
| 219 | + - name: Ccache installation cache |
| 220 | + id: ccache-installation-cache |
| 221 | + uses: actions/cache@v4 |
| 222 | + with: |
| 223 | + path: | |
| 224 | + C:\ProgramData\chocolatey\lib\ccache |
| 225 | + C:\ProgramData\chocolatey\bin\ccache.exe |
| 226 | + C:\ccache\cl.exe |
| 227 | + key: ${{ github.job }}-ccache-installation-${{ env.CI_CCACHE_VERSION }} |
| 228 | + |
| 229 | + - name: Install Ccache |
| 230 | + if: steps.ccache-installation-cache.outputs.cache-hit != 'true' |
| 231 | + run: | |
| 232 | + choco install --yes --no-progress ccache --version=$env:CI_CCACHE_VERSION |
| 233 | + New-Item -ItemType Directory -Path "C:\ccache" |
| 234 | + Copy-Item -Path "$env:ChocolateyInstall\lib\ccache\tools\ccache-$env:CI_CCACHE_VERSION-windows-x86_64\ccache.exe" -Destination "C:\ccache\cl.exe" |
| 235 | +
|
| 236 | + - name: Restore Ccache cache |
| 237 | + id: ccache-cache |
| 238 | + uses: actions/cache/restore@v4 |
| 239 | + with: |
| 240 | + path: ~/AppData/Local/ccache |
| 241 | + key: ${{ github.job }}-ccache-${{ github.run_id }} |
| 242 | + restore-keys: ${{ github.job }}-ccache- |
| 243 | + |
| 244 | + - name: Using vcpkg with MSBuild |
| 245 | + run: | |
| 246 | + Set-Location "$env:VCPKG_INSTALLATION_ROOT" |
| 247 | + Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)" |
| 248 | + Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_PLATFORM_TOOLSET_VERSION $env:VCToolsVersion)" |
| 249 | + .\vcpkg.exe --vcpkg-root "$env:VCPKG_INSTALLATION_ROOT" integrate install |
| 250 | + git rev-parse HEAD | Out-File -FilePath "$env:GITHUB_WORKSPACE\vcpkg_commit" |
| 251 | + Get-Content -Path "$env:GITHUB_WORKSPACE\vcpkg_commit" |
| 252 | +
|
| 253 | + - name: vcpkg tools cache |
| 254 | + uses: actions/cache@v4 |
| 255 | + with: |
| 256 | + path: C:/vcpkg/downloads/tools |
| 257 | + key: ${{ github.job }}-vcpkg-tools |
| 258 | + |
| 259 | + - name: vcpkg binary cache |
| 260 | + uses: actions/cache@v4 |
| 261 | + with: |
| 262 | + path: ~/AppData/Local/vcpkg/archives |
| 263 | + key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('vcpkg_commit', 'msbuild_version', 'toolset_version', 'build_msvc/vcpkg.json') }} |
| 264 | + |
| 265 | + - name: Generate project files |
| 266 | + run: py -3 build_msvc\msvc-autogen.py |
| 267 | + |
| 268 | + - name: Build |
| 269 | + shell: cmd |
| 270 | + run: | |
| 271 | + ccache --zero-stats |
| 272 | + msbuild build_msvc\bitcoin.sln -property:CLToolPath=C:\ccache;CLToolExe=cl.exe;UseMultiToolTask=true;Configuration=Release -maxCpuCount -verbosity:minimal -noLogo |
| 273 | +
|
| 274 | + - name: Ccache stats |
| 275 | + run: ccache --show-stats |
| 276 | + |
| 277 | + - name: Save Ccache cache |
| 278 | + uses: actions/cache/save@v4 |
| 279 | + if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true' |
| 280 | + with: |
| 281 | + path: ~/AppData/Local/ccache |
| 282 | + # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache |
| 283 | + key: ${{ github.job }}-ccache-${{ github.run_id }} |
| 284 | + |
| 285 | + - name: Run unit tests |
| 286 | + run: src\test_bitcoin.exe -l test_suite |
| 287 | + |
| 288 | + - name: Run benchmarks |
| 289 | + run: src\bench_bitcoin.exe -sanity-check |
| 290 | + |
| 291 | + - name: Run util tests |
| 292 | + run: py -3 test\util\test_runner.py |
| 293 | + |
| 294 | + - name: Run rpcauth test |
| 295 | + run: py -3 test\util\rpcauth-test.py |
| 296 | + |
| 297 | + - name: Run functional tests |
| 298 | + env: |
| 299 | + TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }} |
| 300 | + shell: cmd |
| 301 | + run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA% |
0 commit comments