remove --platform=$BUILDPLATFORM #121
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
# Build CCGL library on native C++11 with mongo-c-driver and run test with CMake | |
name: Build with MongoDB | |
on: | |
push: | |
paths-ignore: | |
- 'doc/**' | |
pull_request: | |
paths-ignore: | |
- 'doc/**' | |
workflow_dispatch: | |
env: | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Debug | |
jobs: | |
build-linux-ubuntu: | |
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. | |
# You can convert this to a matrix build if you need cross-platform coverage. | |
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
runs-on: ubuntu-latest | |
services: | |
mongodb: | |
image: mongo | |
ports: | |
- 27017:27017 | |
steps: | |
- name: Checkout CCGL | |
uses: actions/checkout@v3 | |
# 1. https://github.com/supercharge/mongodb-github-action | |
# - name: MongoDB in GitHub Actions | |
# uses: supercharge/[email protected] | |
# 2. launch manually (untested) | |
# - name: launch | |
# shell: bash | |
# run: | | |
# mkdir /tmp/d | |
# mongod --dbpath /tmp/d --fork --logpath /tmp/log | |
# sleep 5 | |
# echo 'db' | mongo 127.0.0.1 | |
- name: Install mongo-c-driver | |
run: sudo apt-get update && sudo apt-get install -qq libmongoc-1.0-0 libmongoc-dev | |
- name: Configure CMake | |
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | |
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | |
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUNITTEST=1 | |
- name: Build | |
# Build your program with the given configuration | |
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | |
- name: Test | |
working-directory: ${{github.workspace}}/build | |
# Execute tests defined by the CMake configuration. | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure | |
build-windows: | |
runs-on: windows-2019 | |
steps: | |
- name: Checkout CCGL | |
uses: actions/checkout@v3 | |
- name: Find mongod.exe | |
run: where.exe mongod.exe | |
# C:\Program Files\MongoDB\Server\5.0\bin\mongod.exe | |
- name: Start MongoDB Service | |
# How to start MongoDB as a service on Windows runners | |
# https://github.com/orgs/community/discussions/30083#discussioncomment-3448499 | |
shell: pwsh | |
run: | | |
Set-Service mongodb -StartupType Automatic | |
Start-Service -Name mongodb | |
- name: Download mongo-c-driver | |
# Build mongo-c-driver is time-consuming, I moved it to another repo. https://github.com/crazyzlj/Github_Actions_Precompiled_Packages | |
# run: ${{github.workspace}}\.github\workflows\build_mongo-c-driver.ps1 | |
# Instead, download the prebuilt library directly. | |
# | |
# Set Env, refers to https://github.com/mstum/Simplexcel/blob/master/.github/workflows/cibuild.yml | |
id: pwshdownmongo | |
shell: pwsh | |
run: | | |
cd ${{github.workspace}}\.github\workflows | |
./download_mongo-c-driver.ps1 -mongoCPath ${{github.workspace}}/mongolib | |
Get-ChildItem Env: | Where-Object {$_.Name -Match "^MONGO"} | %{ echo "$($_.Name)=$($_.Value)" >> $env:GITHUB_ENV } | |
- name: Configure CMake | |
shell: cmd | |
run: | | |
cmake -G "Visual Studio 16 2019" -A x64 -B ${{github.workspace}}/build ^ | |
-DMONGOC_ROOT=${{ env.MONGOC_ROOT }} ^ | |
-DUNITTEST=1 | |
- name: Build | |
shell: cmd | |
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- /m:2 | |
- name: Test | |
shell: cmd | |
working-directory: ${{github.workspace}}/build | |
run: | | |
set PATH=${{ env.MONGOC_BIN }};%PATH% | |
ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure | |
build-mac: | |
runs-on: macos-latest | |
steps: | |
- name: Setup xcode | |
uses: maxim-lobanov/setup-xcode@v1 | |
# Default MongoBD was preinstalled on macos-12 and macos-11 | |
# see https://github.com/actions/runner-images/tree/main/images/macos | |
# | |
# default mongod install path: /usr/local/bin/mongod | |
# default mongod.conf: /usr/local/etc/mongod.conf | |
# systemLog: | |
# destination: file | |
# path: /usr/local/var/log/mongodb/mongo.log | |
# logAppend: true | |
# storage: | |
# dbPath: /usr/local/var/mongodb | |
# net: | |
# bindIp: 127.0.0.1 | |
# | |
# - name: Check mongod | |
# run: | | |
# which mongod | |
# cat /usr/local/etc/mongod.conf | |
# - name: Start mongod manually | |
# run: mongod --config /usr/local/etc/mongod.conf --fork | |
# https://github.com/ankane/setup-mongodb | |
- name: Setup MongoDB | |
uses: ankane/setup-mongodb@v1 | |
with: | |
mongodb-version: 7.0 | |
- name: Run MongoDB | |
run: mongosh --eval "db.version()" | |
- name: Install mongo-c-driver | |
run: brew install mongo-c-driver | |
- name: Checkout CCGL | |
uses: actions/checkout@v3 | |
- name: Configure CMake | |
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUNITTEST=1 | |
- name: Build | |
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | |
- name: Test | |
working-directory: ${{github.workspace}}/build | |
run: ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure |