Fix copyright year #35
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
name: nimLUA CI | |
on: [push, pull_request] | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
max-parallel: 20 | |
matrix: | |
test_lang: [c, cpp] | |
branch: [master] | |
target: | |
- os: linux | |
cpu: amd64 | |
- os: linux | |
cpu: i386 | |
- os: macos | |
cpu: amd64 | |
- os: windows | |
cpu: amd64 | |
- os: windows | |
cpu: i386 | |
include: | |
- target: | |
os: linux | |
builder: ubuntu-20.04 | |
- target: | |
os: macos | |
builder: macos-11 | |
- target: | |
os: windows | |
builder: windows-latest | |
defaults: | |
run: | |
shell: bash | |
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }} (${{ matrix.branch }})' | |
runs-on: ${{ matrix.builder }} | |
steps: | |
- name: Checkout nimLUA | |
uses: actions/checkout@v3 | |
with: | |
path: nimLUA | |
submodules: false | |
- name: Install build dependencies (Linux i386) | |
if: runner.os == 'Linux' && matrix.target.cpu == 'i386' | |
run: | | |
sudo dpkg --add-architecture i386 | |
sudo apt-fast update -qq | |
sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \ | |
--no-install-recommends -yq gcc-multilib g++-multilib \ | |
libssl-dev:i386 | |
mkdir -p external/bin | |
cat << EOF > external/bin/gcc | |
#!/bin/bash | |
exec $(which gcc) -m32 "\$@" | |
EOF | |
cat << EOF > external/bin/g++ | |
#!/bin/bash | |
exec $(which g++) -m32 "\$@" | |
EOF | |
chmod 755 external/bin/gcc external/bin/g++ | |
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH | |
- name: Restore llvm-mingw (Windows) from cache | |
if: runner.os == 'Windows' | |
id: windows-mingw-cache | |
uses: actions/cache@v3 | |
with: | |
path: external/mingw-${{ matrix.target.cpu }} | |
key: 'mingw-llvm-${{ matrix.target.cpu }}' | |
- name: Restore Nim DLLs dependencies (Windows) from cache | |
if: runner.os == 'Windows' | |
id: windows-dlls-cache | |
uses: actions/cache@v3 | |
with: | |
path: external/dlls-${{ matrix.target.cpu }} | |
key: 'dlls-${{ matrix.target.cpu }}' | |
- name: Install llvm-mingw dependency (Windows) | |
if: > | |
steps.windows-mingw-cache.outputs.cache-hit != 'true' && | |
runner.os == 'Windows' | |
run: | | |
mkdir -p external | |
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905" | |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then | |
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip" | |
ARCH=64 | |
else | |
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-i686.zip" | |
ARCH=32 | |
fi | |
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip" | |
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/ | |
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }} | |
- name: Install DLLs dependencies (Windows) | |
if: > | |
steps.windows-dlls-cache.outputs.cache-hit != 'true' && | |
runner.os == 'Windows' | |
run: | | |
mkdir -p external | |
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip | |
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }} | |
- name: Path to cached dependencies (Windows) | |
if: > | |
runner.os == 'Windows' | |
run: | | |
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH | |
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH | |
- name: Setup environment | |
run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH | |
- name: Get latest Nim commit hash | |
id: versions | |
run: | | |
getHash() { | |
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1 | |
} | |
nimHash=$(getHash nim-lang/Nim devel) | |
csourcesHash=$(getHash nim-lang/csources_v2) | |
echo "nim=$nimHash" >> $GITHUB_OUTPUT | |
echo "csources=$csourcesHash" >> $GITHUB_OUTPUT | |
- name: Restore prebuilt Nim from cache | |
id: nim-cache | |
uses: actions/cache@v3 | |
with: | |
path: nim | |
key: '${{ matrix.test_lang }}-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nim }}' | |
- name: Restore prebuilt csources from cache | |
if: steps.nim-cache.outputs.cache-hit != 'true' | |
id: csources-cache | |
uses: actions/cache@v3 | |
with: | |
path: csources/bin | |
key: 'csources-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.csources }}' | |
- name: Checkout Nim csources | |
if: > | |
steps.csources-cache.outputs.cache-hit != 'true' && | |
steps.nim-cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: nim-lang/csources_v2 | |
path: csources | |
ref: ${{ steps.versions.outputs.csources }} | |
- name: Checkout Nim | |
if: steps.nim-cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: nim-lang/Nim | |
path: nim | |
ref: ${{ steps.versions.outputs.nim }} | |
- name: Build Nim and associated tools | |
if: steps.nim-cache.outputs.cache-hit != 'true' | |
run: | | |
ncpu= | |
ext= | |
case '${{ runner.os }}' in | |
'Linux') | |
ncpu=$(nproc) | |
;; | |
'macOS') | |
ncpu=$(sysctl -n hw.ncpu) | |
;; | |
'Windows') | |
ncpu=$NUMBER_OF_PROCESSORS | |
ext=.exe | |
;; | |
esac | |
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1 | |
if [[ ! -e csources/bin/nim$ext ]]; then | |
make -C csources -j $ncpu CC=gcc ucpu='${{ matrix.target.cpu }}' | |
else | |
echo 'Using prebuilt csources' | |
fi | |
cp -v csources/bin/nim$ext nim/bin | |
cd nim | |
nim c koch | |
./koch boot -d:release | |
./koch nimble -d:release | |
# clean up to save cache space | |
rm koch | |
rm -rf nimcache | |
rm -rf dist | |
rm -rf .git | |
- name: Restore prebuilt Lua from cache | |
id: lua-cache | |
uses: actions/cache@v3 | |
with: | |
path: nimLUA/external | |
key: 'lua-${{ matrix.target.os }}-${{ matrix.target.cpu }}' | |
- name : Download and build lualib | |
if: steps.lua-cache.outputs.cache-hit != 'true' | |
run: | | |
EXTPATH=nimLUA/external | |
mkdir -p "$EXTPATH" | |
curl -L https://www.lua.org/ftp/lua-5.3.5.tar.gz -o "$EXTPATH/lua_source.tar.gz" | |
tar xfz "$EXTPATH/lua_source.tar.gz" -C "$EXTPATH" | |
mv "$EXTPATH/lua-5.3.5" lua | |
cd nimLUA | |
nim e scripts/build_static_lib.nims | |
cd .. | |
- name: Run nimLUA tests | |
run: | | |
cd nimLUA | |
env TEST_LANG="${{ matrix.test_lang }}" nimble test |