aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-01-18 15:32:28 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-01-18 20:51:19 +0300
commitca3ac59b71a1d613f7d978f12d9593f68b7ee907 (patch)
tree79a02e4d3c3e657040b39b0df1eab796a86fbff4
parentproject.ci: --install picks the directory automatically (diff)
downloadcmake-common-ca3ac59b71a1d613f7d978f12d9593f68b7ee907.tar.gz
cmake-common-ca3ac59b71a1d613f7d978f12d9593f68b7ee907.zip
project.ci: add GitHub Actions
-rw-r--r--.github/workflows/ci_appveyor.yml6
-rw-r--r--.github/workflows/ci_github.yml76
-rw-r--r--.github/workflows/ci_travis.yml6
-rw-r--r--README.md20
-rw-r--r--project/ci/cmake.py8
-rw-r--r--project/ci/dirs.py17
-rw-r--r--project/ci/github/__init__.py0
-rw-r--r--project/ci/github/boost.py17
-rw-r--r--project/ci/github/cmake.py17
9 files changed, 155 insertions, 12 deletions
diff --git a/.github/workflows/ci_appveyor.yml b/.github/workflows/ci_appveyor.yml
index 8427e43..728c378 100644
--- a/.github/workflows/ci_appveyor.yml
+++ b/.github/workflows/ci_appveyor.yml
@@ -52,12 +52,10 @@ jobs:
run: mkdir C:\projects
- name: Build Boost
- run: |
- python -m project.ci.appveyor.boost -- --with-filesystem
+ run: python -m project.ci.appveyor.boost -- --with-filesystem
- name: Build example project
- run: |
- python -m project.ci.appveyor.cmake --install
+ run: python -m project.ci.appveyor.cmake --install
- name: Run example project
run: |
diff --git a/.github/workflows/ci_github.yml b/.github/workflows/ci_github.yml
new file mode 100644
index 0000000..b6f3ec5
--- /dev/null
+++ b/.github/workflows/ci_github.yml
@@ -0,0 +1,76 @@
+# The project.ci.github package is tested.
+
+name: CI (GitHub)
+
+on:
+ push:
+ branches-ignore:
+ - travis
+ - appveyor
+ pull_request:
+ schedule:
+ # Weekly, at 5:30 AM on Saturday (somewhat randomly chosen).
+ - cron: '30 5 * * 6'
+ workflow_dispatch:
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ os: [ubuntu-18.04, windows-2019]
+ configuration: [Debug, Release]
+ include:
+ # Prettier run names.
+ - {os: ubuntu-18.04, name: Ubuntu}
+ - {os: windows-2019, name: VS 2019}
+
+ runs-on: '${{ matrix.os }}'
+
+ name: '${{ matrix.name }} / ${{ matrix.configuration }}'
+
+ env:
+ platform: x64
+ configuration: '${{ matrix.configuration }}'
+ boost_version: 1.72.0
+
+ defaults:
+ run:
+ shell: pwsh
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.x'
+
+ - name: Build Boost
+ run: python -m project.ci.github.boost -- --with-filesystem
+
+ - name: Build example project
+ run: python -m project.ci.github.cmake --install --subdir examples/boost -- -D Boost_DEBUG=ON
+
+ - name: Run example project
+ run: |
+ cd (Join-Path $env:GITHUB_WORKSPACE .. install bin)
+ $foo_path = Join-Path (Get-Location).Path foo
+ if ('${{ runner.os }}' -eq 'Windows') {
+ $foo_path += '.exe'
+ }
+
+ $relative = 'test.txt'
+ $absolute = Join-Path (Get-Location).Path $relative
+
+ $actual = & $foo_path $relative
+ echo 'Actual output:'
+ echo $actual
+
+ $expected = $foo_path,$absolute
+ echo 'Expected output:'
+ echo $expected
+
+ if (Compare-Object $actual $expected -CaseSensitive) {
+ throw 'Unexpected output'
+ }
diff --git a/.github/workflows/ci_travis.yml b/.github/workflows/ci_travis.yml
index 060970d..495a645 100644
--- a/.github/workflows/ci_travis.yml
+++ b/.github/workflows/ci_travis.yml
@@ -46,12 +46,10 @@ jobs:
python-version: '3.x'
- name: Build Boost
- run: |
- python -m project.ci.travis.boost -- --with-filesystem
+ run: python -m project.ci.travis.boost -- --with-filesystem
- name: Build example project
- run: |
- python -m project.ci.travis.cmake --install
+ run: python -m project.ci.travis.cmake --install
- name: Run example project
run: |
diff --git a/README.md b/README.md
index 67f7584..3e01beb 100644
--- a/README.md
+++ b/README.md
@@ -97,7 +97,7 @@ Bootstrap Boost and/or build a CMake project:
$ python3 -m project.ci.travis.boost -- --with-test
- $ python3 -m project.ci.travis.cmake --install "$HOME/install"
+ $ python3 -m project.ci.travis.cmake --install
Environment variables:
@@ -110,9 +110,9 @@ Environment variables:
Bootstrap Boost (seldom used, since AppVeyor pre-builds many Boost versions)
and/or build a CMake project:
- > C:\Python36-x64\python.exe -m project.ci.appveyor.boost -- --with-test
+ > C:\Python36-x64\python.exe -m project.ci.appveyor.boost -- --with-filesystem
- > C:\Python36-x64\python.exe -m project.ci.appveyor.cmake --install C:\projects\install
+ > C:\Python36-x64\python.exe -m project.ci.appveyor.cmake --install
Environment variables:
@@ -120,6 +120,20 @@ Environment variables:
* `CONFIGURATION`,
* `boost_version`.
+#### GitHub Actions
+
+Bootstrap Boost and/or build a CMake project:
+
+ > python -m project.ci.github.boost -- --with-program_options
+
+ > python -m project.ci.github.cmake --install
+
+Environment variables:
+
+* `platform`,
+* `configuration`,
+* `boost_version`.
+
### clang-format.py
`clang-format` all C/C++ files in a project.
diff --git a/project/ci/cmake.py b/project/ci/cmake.py
index 67ad13a..262aafa 100644
--- a/project/ci/cmake.py
+++ b/project/ci/cmake.py
@@ -5,6 +5,7 @@
import argparse
import logging
+import os.path
import sys
from project.cmake.build import BuildParameters, build
@@ -27,6 +28,8 @@ def _parse_args(dirs, argv=None):
parser.add_argument('--toolset', metavar='TOOLSET',
type=ToolchainType.parse,
help='toolset to use')
+ parser.add_argument('--subdir', metavar='DIR',
+ help='relative project directory path')
parser.add_argument('cmake_args', nargs='*', metavar='CMAKE_ARG', default=[],
help='additional CMake arguments, to be passed verbatim')
return parser.parse_args(argv)
@@ -35,8 +38,11 @@ def _parse_args(dirs, argv=None):
def build_ci(dirs, argv=None):
args = _parse_args(dirs, argv)
+ src_dir = dirs.get_src_dir()
+ if args.subdir:
+ src_dir = os.path.join(src_dir, args.subdir)
install_dir = dirs.get_install_dir() if args.install else None
- params = BuildParameters(dirs.get_src_dir(),
+ params = BuildParameters(src_dir,
build_dir=dirs.get_cmake_dir(),
install_dir=install_dir,
platform=dirs.get_platform(),
diff --git a/project/ci/dirs.py b/project/ci/dirs.py
index 4e61015..6c6de65 100644
--- a/project/ci/dirs.py
+++ b/project/ci/dirs.py
@@ -100,3 +100,20 @@ class AppVeyor(Dirs):
def get_cmake_args(self):
return ['-G', str(Generator.from_image(Image.get()))]
+
+
+class GitHub(Dirs):
+ def get_platform(self):
+ return Platform.parse(env('platform'))
+
+ def get_configuration(self):
+ return Configuration.parse(env('configuration'))
+
+ def get_src_dir(self):
+ return env('GITHUB_WORKSPACE')
+
+ def get_build_dir(self):
+ return os.path.dirname(env('GITHUB_WORKSPACE'))
+
+ def get_cmake_args(self):
+ return []
diff --git a/project/ci/github/__init__.py b/project/ci/github/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/project/ci/github/__init__.py
diff --git a/project/ci/github/boost.py b/project/ci/github/boost.py
new file mode 100644
index 0000000..5fd1e48
--- /dev/null
+++ b/project/ci/github/boost.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "cmake-common" project.
+# For details, see https://github.com/egor-tensin/cmake-common.
+# Distributed under the MIT License.
+
+from project.ci.boost import build_ci
+from project.ci.dirs import GitHub
+from project.utils import setup_logging
+
+
+def main(argv=None):
+ with setup_logging():
+ build_ci(GitHub(), argv)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/project/ci/github/cmake.py b/project/ci/github/cmake.py
new file mode 100644
index 0000000..9b9c7b9
--- /dev/null
+++ b/project/ci/github/cmake.py
@@ -0,0 +1,17 @@
+# Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "cmake-common" project.
+# For details, see https://github.com/egor-tensin/cmake-common.
+# Distributed under the MIT License.
+
+from project.ci.cmake import build_ci
+from project.ci.dirs import GitHub
+from project.utils import setup_logging
+
+
+def main(argv=None):
+ with setup_logging():
+ build_ci(GitHub(), argv)
+
+
+if __name__ == '__main__':
+ main()