270 lines
7.5 KiB
Plaintext
270 lines
7.5 KiB
Plaintext
## Building Nim projects on Circle CI
|
|
|
|
Building your code on Circle CI is useful to check regressions against the master and devel branches of Nim.
|
|
Same for your code documentation.
|
|
|
|
Configure the build:
|
|
|
|
Under Test Commands >> Dependency Commands >> Pre-dependency commands:
|
|
[source,sh]
|
|
----
|
|
wget http://http.us.debian.org/debian/pool/main/n/nim/nim_0.18.0-2_amd64.deb
|
|
wget http://http.us.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.0h-4_amd64.deb
|
|
sudo dpkg -i *_amd64.deb
|
|
----
|
|
|
|
Under Test Commands >> Test Commands >> Test Commands:
|
|
[source,sh]
|
|
----
|
|
# This will fetch Nimble dependencies
|
|
nimble build -y
|
|
nim c -r <mytest.nim>
|
|
----
|
|
|
|
Be aware that the available .deb packages will change over time.
|
|
|
|
### Using CircleCI 2.0 with choosenim
|
|
|
|
choosenim allow picking fixed Nim versions or updating to the last stable or devel version
|
|
|
|
Use this .circleci/config.yml
|
|
|
|
---
|
|
version: 2
|
|
jobs:
|
|
build:
|
|
machine: true
|
|
steps:
|
|
- run: echo 'export PATH=~/.nimble/bin:$PATH' >> $BASH_ENV
|
|
- checkout
|
|
# Reuse cached Nim compiler
|
|
- restore_cache:
|
|
key: compiler-0002
|
|
- run:
|
|
command: |
|
|
if [ -f ~/.nimble/bin/choosenim ]; then
|
|
echo "Updating Nim using choosenim"
|
|
choosenim stable
|
|
else
|
|
echo "Installing choosenim and Nim"
|
|
wget https://raw.githubusercontent.com/dom96/choosenim/master/scripts/choosenim-unix-init.sh
|
|
sh choosenim-unix-init.sh -y
|
|
fi
|
|
- save_cache:
|
|
key: compiler-0002
|
|
paths:
|
|
- ~/.nimble
|
|
- ~/.choosenim
|
|
- run:
|
|
command: |
|
|
nimble build -y
|
|
# add here your tests
|
|
---
|
|
|
|
## Building Nim projects on Circle CI v2.0 using Nim Devel
|
|
|
|
Create .circleci/config.yml as:
|
|
|
|
[source,yaml]
|
|
----
|
|
version: 2
|
|
jobs:
|
|
build:
|
|
machine: true
|
|
steps:
|
|
- run: echo 'export PATH=./Nim/bin:$PATH' >> $BASH_ENV
|
|
- checkout
|
|
# Reuse cached Nim compiler
|
|
- restore_cache:
|
|
key: compiler-0000
|
|
- run:
|
|
command: |
|
|
if [ -d Nim ]; then
|
|
cd Nim
|
|
git fetch
|
|
if [ "$(git rev-parse HEAD)" == "$(git rev-parse @{u})" ]; then
|
|
echo "Nim is up to date"
|
|
build_nim=false
|
|
else
|
|
echo "pulling new Nim commits"
|
|
build_nim=true
|
|
git pull
|
|
fi
|
|
else
|
|
echo "cloning Nim for the first time"
|
|
build_nim=true
|
|
git clone --depth 1 https://github.com/nim-lang/Nim.git
|
|
cd Nim
|
|
git clone --depth 1 git://github.com/nim-lang/csources.git csources
|
|
cd csources
|
|
sh build.sh
|
|
cd ..
|
|
fi
|
|
if [ "$build_nim" = true ]; then
|
|
./bin/nim c koch
|
|
./koch boot -d:release
|
|
./koch tools
|
|
fi
|
|
- save_cache:
|
|
key: compiler-0000
|
|
paths:
|
|
- Nim
|
|
- run: nimble build -y
|
|
- run: nim c -r <mytest.nim>
|
|
- store_artifacts:
|
|
path: test-reports/
|
|
destination: tr1
|
|
- store_test_results:
|
|
path: test-reports/
|
|
----
|
|
|
|
## Building Nim projects on Circle CI v2.0 with Docker
|
|
|
|
On Circle CI 2.0 you can use Docker containers to perform builds. The following example is taken from the following guide and builds against the current Nim version on both Ubuntu and Alpine Linux: https://www.euantorano.co.uk/posts/nim-circle-ci/[Continuous Integration for Nim using Circle CI]
|
|
|
|
[source,yaml]
|
|
----
|
|
version: 2
|
|
jobs:
|
|
build:
|
|
working_directory: /usr/src/dotenv
|
|
docker:
|
|
- image: nimlang/nim
|
|
branches:
|
|
only:
|
|
- master
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: test
|
|
command: nim c -r tests/main.nim
|
|
build_alpine:
|
|
working_directory: /usr/src/dotenv
|
|
docker:
|
|
- image: nimlang/nim:alpine
|
|
branches:
|
|
only:
|
|
- master
|
|
steps:
|
|
- checkout
|
|
- run:
|
|
name: test
|
|
command: nim c -r tests/main.nim
|
|
workflows:
|
|
version: 2
|
|
build_and_test:
|
|
jobs:
|
|
- build
|
|
- build_alpine
|
|
----
|
|
|
|
## Building Nim projects on Travis CI
|
|
|
|
Building your code on Travis CI is useful to check regressions against the master and devel branches of Nim.
|
|
Same for your code documentation.
|
|
|
|
Detailed guide, which the following example originates from: +
|
|
http://blaxpirit.com/blog/22/advanced-uses-of-travis-ci-with-nim.html[Advanced uses of Travis CI with Nim]
|
|
|
|
If you don't want to rebuild the Nim compiler you can instead install the .deb packages listed on the CircleCI guide above using https://docs.travis-ci.com/user/installing-dependencies[this config]
|
|
|
|
[source,yaml]
|
|
----
|
|
# Copied from https://github.com/nim-lang/Nim/wiki/TravisCI
|
|
language: c
|
|
env:
|
|
# Build and test against the master and devel branches of Nim
|
|
- BRANCH=master
|
|
- BRANCH=devel
|
|
compiler:
|
|
# Build and test using both gcc and clang
|
|
- gcc
|
|
- clang
|
|
matrix:
|
|
allow_failures:
|
|
# Ignore failures when building against the devel Nim branch
|
|
- env: BRANCH=devel
|
|
fast_finish: true
|
|
install:
|
|
- |
|
|
if [ ! -x nim-$BRANCH/bin/nim ]; then
|
|
git clone -b $BRANCH --depth 1 git://github.com/nim-lang/nim nim-$BRANCH/
|
|
cd nim-$BRANCH
|
|
git clone --depth 1 git://github.com/nim-lang/csources csources/
|
|
cd csources
|
|
sh build.sh
|
|
cd ..
|
|
rm -rf csources
|
|
bin/nim c koch
|
|
./koch boot -d:release
|
|
else
|
|
cd nim-$BRANCH
|
|
git fetch origin
|
|
if ! git merge FETCH_HEAD | grep "Already up-to-date"; then
|
|
bin/nim c koch
|
|
./koch boot -d:release
|
|
fi
|
|
fi
|
|
cd ..
|
|
before_script:
|
|
- export PATH="nim-$BRANCH/bin${PATH:+:$PATH}"
|
|
script:
|
|
# Replace uppercase strings!
|
|
- nim c --cc:$CC --verbosity:0 -r MYFILE.nim
|
|
# Optional: build docs.
|
|
- nim doc --docSeeSrcUrl:https://github.com/AUTHOR/MYPROJECT/blob/master --project MYFILE.nim
|
|
cache:
|
|
directories:
|
|
- nim-master
|
|
- nim-devel
|
|
branches:
|
|
except:
|
|
- gh-pages
|
|
|
|
----
|
|
|
|
## Appveyor
|
|
|
|
Create .appveyor.yml
|
|
|
|
[source,yaml]
|
|
----
|
|
version: '{build}'
|
|
|
|
cache:
|
|
- nim-0.16.0_x64.zip
|
|
- x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z
|
|
|
|
matrix:
|
|
fast_finish: true
|
|
|
|
environment:
|
|
matrix:
|
|
- MINGW_ARCHIVE: x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z
|
|
MINGW_DIR: mingw64
|
|
MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download
|
|
NIM_ARCHIVE: nim-0.16.0_x64.zip
|
|
NIM_DIR: nim-0.16.0
|
|
NIM_URL: https://nim-lang.org/download/nim-0.16.0_x64.zip
|
|
platform: x64
|
|
|
|
install:
|
|
- MKDIR %CD%\tools_tmp
|
|
- IF not exist "%MINGW_ARCHIVE%" appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%"
|
|
- 7z x -y "%MINGW_ARCHIVE%" -o"%CD%\tools_tmp"> nul
|
|
- IF not exist "%NIM_ARCHIVE%" appveyor DownloadFile "%NIM_URL%" -FileName "%NIM_ARCHIVE%"
|
|
- 7z x -y "%NIM_ARCHIVE%" -o"%CD%\tools_tmp"> nul
|
|
- SET PATH=%CD%\tools_tmp\%NIM_DIR%\bin;%CD%\tools_tmp\%MINGW_DIR%\bin;%PATH%
|
|
|
|
build_script:
|
|
- nimble.exe install CHANGEME -y
|
|
- nim.exe c -p:. ./tests/CHANGEME.nim
|
|
|
|
test_script:
|
|
- ./tests/CHANGEME
|
|
|
|
deploy: off
|
|
----
|
|
|
|
You may encounter an issue with Sourceforge download and download just a webpage. In that case replace the generic URL by a direct link into a mirror like 'https://ayera.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z'
|