From a35c7bc6315afa7f0473774282df7cd2493036a8 Mon Sep 17 00:00:00 2001 From: Andrea Pappacoda Date: Sat, 12 Feb 2022 14:28:19 +0100 Subject: [PATCH] ci: switch to GitHub Actions --- .circleci/config.yml | 143 ------------------------- .github/workflows/ci.yaml | 109 +++++++++++++++++++ .github/workflows/gh-pages.yaml | 36 +++++++ README.md | 2 +- tools/ci_single_header_check.py | 0 tools/generate_conformance_tests.py | 0 tools/generate_single_header.py | 0 tools/generate_windows_test_targets.py | 0 8 files changed, 146 insertions(+), 144 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/gh-pages.yaml mode change 100644 => 100755 tools/ci_single_header_check.py mode change 100644 => 100755 tools/generate_conformance_tests.py mode change 100644 => 100755 tools/generate_single_header.py mode change 100644 => 100755 tools/generate_windows_test_targets.py diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1b0d06e..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,143 +0,0 @@ -version: 2 - -jobs: - - debug_clang: - docker: - - image: marzer/cpp_dev:0.2.0 - resource_class: large - steps: - - checkout - - run: - name: Installing dependencies - command: | - pip3 install --upgrade -r tools/requirements.txt - - run: - name: Checking toml.hpp - command: | - cd tools && python3 ci_single_header_check.py - - run: - name: Pulling submodules - command: | - git submodule update --init --depth 1 external/Catch2 external/tloptional - - run: - name: Building and testing with clang - command: | - update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-13 130 - CXX_LD=lld CXX=clang++ meson build --buildtype=debug -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false -Db_lto=false -Dasan_examples=true - cd build && meson compile -j 4 && meson test --num-processes 1 --verbose - - release_clang: - docker: - - image: marzer/cpp_dev:0.2.0 - resource_class: large - steps: - - checkout - - run: - name: Pulling submodules - command: | - git submodule update --init --depth 1 external/Catch2 external/tloptional - - run: - name: Building and testing with clang - command: | - update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-13 130 - CXX_LD=lld CXX=clang++ meson build --buildtype=release -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false -Db_lto=false -Dasan_examples=true - cd build && meson compile -j 4 && meson test --num-processes 1 --verbose - - debug_gcc: - docker: - - image: marzer/cpp_dev:0.2.0 - resource_class: large - steps: - - checkout - - run: - name: Pulling submodules - command: | - git submodule update --init --depth 1 external/Catch2 external/tloptional - - run: - name: Building and testing with gcc - command: | - update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-13 130 - CXX_LD=lld CXX=g++ meson build --buildtype=debug -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false -Db_lto=false - cd build && meson compile -j 4 && meson test --num-processes 1 --verbose - - release_gcc: - docker: - - image: marzer/cpp_dev:0.2.0 - resource_class: large - steps: - - checkout - - run: - name: Pulling submodules - command: | - git submodule update --init --depth 1 external/Catch2 external/tloptional - - run: - name: Building and testing with gcc - command: | - update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-13 130 - CXX_LD=lld CXX=g++ meson build --buildtype=release -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false -Db_lto=false - cd build && meson compile -j 4 && meson test --num-processes 1 --verbose - - generate_dox: - docker: - - image: marzer/cpp_dev:0.2.0 - resource_class: small - steps: - - checkout - - run: - name: Installing dependencies - command: | - pip3 install --upgrade -r tools/requirements.txt - - run: - name: Generating documentation - command: | - cd docs && poxy --verbose - - persist_to_workspace: - root: docs - paths: html - - deploy_dox: - docker: - - image: node:14.4.0 - resource_class: small - steps: - - checkout - - attach_workspace: - at: docs - - run: - name: Disable jekyll builds - command: | - touch docs/html/.nojekyll - - run: - name: Installing dependencies - command: | - npm install -g --silent gh-pages@3.0.0 - git config user.email "ci-build@tomlplusplus.com" - git config user.name "ci-build" - - add_ssh_keys: - fingerprints: - - "a6:63:c0:a5:89:cf:2d:03:e7:c9:88:5d:c0:8c:39:e0" - - run: - name: Deploy docs to gh-pages branch - command: gh-pages --dotfiles --message "[skip ci] Updates" --dist docs/html - -workflows: - version: 2 - build: - jobs: - - debug_clang - - release_clang - - debug_gcc - - release_gcc - - generate_dox: - requires: - - debug_clang - - release_clang - - debug_gcc - - release_gcc - filters: - branches: - only: master - - deploy_dox: - requires: - - generate_dox diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..52ca9a9 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,109 @@ +name: ci + +on: [push, pull_request] + +# This ensures that jobs get canceled when force-pushing +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + linux: + strategy: + fail-fast: false + matrix: + compiler: [ 'g++', 'clang' ] + compile: [ true, false ] + + runs-on: ubuntu-latest + container: + image: debian:testing + + defaults: + run: + shell: sh + + steps: + - name: Install dependencies + run: | + apt-get -y update + apt-get -y install --no-install-recommends ${{ matrix.compiler }} lld meson pkgconf git ca-certificates locales-all python3-pip + + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Check toml.hpp + run: | + pip3 install --upgrade --requirement tools/requirements.txt + cd tools + ./ci_single_header_check.py + + - name: Configure Meson + run: | + if [ ${{ matrix.compiler }} = g++ ]; then linker=gold; else linker=lld; fi + CXX_LD=$linker meson setup build --buildtype=debug -Dcompile_library=${{ matrix.compile }} -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false -Db_lto=false -Dasan_examples=true + + - name: Build + run: meson compile -C build + + - name: Test + run: meson test -C build --verbose + + # The Windows job is a mess, but it's a mess with some advantages. + # The job is ran in a clean Docker container, and we have full control on + # the software present there. This also means that every single program + # needs to be manually installed, and since Windows doesn't have a + # package manager installing stuff in scripts is pure pain. + # Also, GitHub's support for Windows containers is really, really bad, + # and the only way of running a job in Docker is by passing everything to + # `docker run`, as a single cmd.exe command. + # Lastly, altering the PATH is almost impossible, and as far as I know + # the only thing that does that reliably is vcvars64.bat; so to make an + # executable available it is necessary to manually move it in a directory + # already in Path, like C:\vs\Common7\Tools\ + windows: + strategy: + fail-fast: false + matrix: + compile: [ true, false ] + + runs-on: windows-2022 + + defaults: + run: + shell: cmd + + steps: + # When the job is triggered by a pull request, we need to fetch the + # "test" merge commit with this command. More info here: + # https://docs.github.com/en/rest/reference/pulls#get-a-pull-request + - name: pull_request fetch command + if: github.event_name == 'pull_request' + run: echo pull_request_fetch_command=git fetch origin +${{ github.event.pull_request.merge_commit_sha }}:${{ github.ref_name }} ^&^& >> %GITHUB_ENV% + + - name: Docker + run: docker run mcr.microsoft.com/windows/servercore:ltsc2022 cmd.exe /c " + mkdir C:\dev && + cd C:\dev && + curl -LO https://aka.ms/vs/17/release.ltsc.17.0/vs_buildtools.exe && + .\vs_buildtools.exe --installPath C:\vs --quiet --norestart --wait --nocache --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 && + C:\vs\VC\Auxiliary\Build\vcvars64.bat && + curl -Lo meson.msi https://github.com/mesonbuild/meson/releases/download/0.61.1/meson-0.61.1-64.msi && + msiexec /a meson.msi TARGETDIR=C:\meson /quiet /qn && + move C:\meson\Meson\* C:\vs\Common7\Tools\ && + curl -Lo git.zip https://github.com/git-for-windows/git/releases/download/v2.35.1.windows.2/MinGit-2.35.1.2-busybox-64-bit.zip && + mkdir git && + cd git && + tar -xf ..\git.zip && + cd .. && + move git\cmd\* C:\vs\Common7\Tools\ && + move git\etc C:\vs\Common7\ && + move git\mingw64 C:\vs\Common7\ && + move git\usr C:\vs\Common7\ && + git clone ${{ github.repositoryUrl }} && + cd tomlplusplus && ${{ env.pull_request_fetch_command }} + git checkout ${{ github.ref_name }} && + meson setup -Dcompile_library=${{ matrix.compile }} -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false build && + meson compile -C build && + meson test -C build" diff --git a/.github/workflows/gh-pages.yaml b/.github/workflows/gh-pages.yaml new file mode 100644 index 0000000..45b26f0 --- /dev/null +++ b/.github/workflows/gh-pages.yaml @@ -0,0 +1,36 @@ +name: gh-pages + +on: + push: + branches: master + paths: docs/** + +jobs: + gh-pages: + runs-on: ubuntu-latest + container: + image: debian:testing + + defaults: + run: + shell: sh + + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: | + apt-get -y update + apt-get -y install --no-install-recommends python3-pip doxygen + pip3 install --upgrade --requirement tools/requirements.txt + + - name: Generate docs + run: | + cd docs + poxy --verbose + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/html diff --git a/README.md b/README.md index 2a41bfa..37cbbb9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![C++20](docs/images/badge-C++20.svg)][cpp_compilers] [![TOML](docs/images/badge-TOML.svg)][v1.0.0] [![MIT license](docs/images/badge-license-MIT.svg)](./LICENSE) -[![CircleCI](https://img.shields.io/circleci/build/github/marzer/tomlplusplus?label=circle%20ci&logo=circleci&logoColor=white&style=flat-square)](https://circleci.com/gh/marzer/tomlplusplus) +[![ci](https://github.com/marzer/tomlplusplus/actions/workflows/ci.yaml/badge.svg)](https://github.com/marzer/tomlplusplus/actions/workflows/ci.yaml) [![Mentioned in Awesome C++](docs/images/badge-awesome.svg)](https://github.com/fffaraz/awesome-cpp) ==== diff --git a/tools/ci_single_header_check.py b/tools/ci_single_header_check.py old mode 100644 new mode 100755 diff --git a/tools/generate_conformance_tests.py b/tools/generate_conformance_tests.py old mode 100644 new mode 100755 diff --git a/tools/generate_single_header.py b/tools/generate_single_header.py old mode 100644 new mode 100755 diff --git a/tools/generate_windows_test_targets.py b/tools/generate_windows_test_targets.py old mode 100644 new mode 100755