Skip to content

Commit

Permalink
Set up CI with Azure Pipelines
Browse files Browse the repository at this point in the history
We only run tests for macOS, since Linux and Windows are already tested on our
other CI.

The code is mirrored to Azure only if the GitLab CI environment variable
SSH_PRIVATE_KEY_AZURE is set. Otherwise the Azure build are skipped.
  • Loading branch information
certik committed Mar 30, 2019
1 parent 731157b commit b9286dc
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ mirror:
only:
- master

# Azure
azure:
stage: tarball
image: registry.gitlab.com/lfortran/ci-images:full-1.2.0
script:
- export PATH="$HOME/conda_root/bin:$PATH"
- sudo apt-get update
- sudo apt-get install -yq --no-install-recommends openssh-client git
- ci/azure_mirror.sh
only:
variables:
- $SSH_PRIVATE_KEY_AZURE


# Test full dependencies when a C compiler is available and used for linking
full:
Expand Down
35 changes: 35 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Azure Pipelines CI
# Documentation of the syntax:
# https://aka.ms/yaml

jobs:
# - job: Linux
# pool:
# vmImage: 'Ubuntu-16.04'
# steps:
# - script: echo Hello, world!

- job: macOS
pool:
# List of preinstalled software on the macOS image:
# https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/macos/macos-Readme.md
vmImage: 'macOS-10.13'
steps:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
- bash: sudo chown -R $USER $CONDA
displayName: Take ownership of conda installation
- script: ci/azure_install_macos.sh
displayName: 'Install prerequisites'

- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
# - job: Windows
# pool:
# vmImage: 'vs2017-win2016'
# steps:
# - script: echo Hello, world!
# displayName: 'Run a one-line script'
27 changes: 27 additions & 0 deletions ci/azure_install_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -ex

conda config --set always_yes yes --set changeps1 no
conda info -a
conda update -q conda
conda install python=3.7 pytest llvmlite prompt_toolkit
pip install antlr4-python3-runtime

python grammar/asdl_py.py
python grammar/asdl_py.py grammar/ASR.asdl lfortran/asr/asr.py ..ast.utils

cd grammar
curl -O https://www.antlr.org/download/antlr-4.7-complete.jar
java -cp antlr-4.7-complete.jar org.antlr.v4.Tool -Dlanguage=Python3 -no-listener -visitor fortran.g4 -o ../lfortran/parser
cd ..

CFLAGS="-Wall -g -fPIC"
gcc $CFLAGS -o lfort_intrinsics.o -c lfort_intrinsics.c
ar rcs liblfortran.a lfort_intrinsics.o
gcc -shared -o liblfortran.so lfort_intrinsics.o
mkdir -p share/lfortran/lib
mv liblfortran.a share/lfortran/lib/
mv liblfortran.so share/lfortran/lib/

pytest
37 changes: 37 additions & 0 deletions ci/azure_mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

set -e
set -x

mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan ssh.dev.azure.com >> ~/.ssh/known_hosts

eval "$(ssh-agent -s)"

set +x
if [[ "${SSH_PRIVATE_KEY_AZURE}" == "" ]]; then
echo "Error: SSH_PRIVATE_KEY_AZURE is empty."
exit 1
fi
# Generate the private/public key pair using:
#
# ssh-keygen -f deploy_key -N ""
#
# then set the $SSH_PRIVATE_KEY_AZURE environment variable in the GitLab-CI to
# the base64 encoded private key:
#
# cat deploy_key | base64 -w0
#
# and add the public key `deploy_key.pub` into the target git repository (with
# write permissions).

ssh-add <(echo "$SSH_PRIVATE_KEY_AZURE" | base64 -d)
set -x

pwd
git branch -D $CI_COMMIT_REF_NAME || echo ok
git checkout -t origin/$CI_COMMIT_REF_NAME
git show-ref
git remote -v
git push git@ssh.dev.azure.com:v3/lfortran/lfortran/lfortran +$CI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME

0 comments on commit b9286dc

Please sign in to comment.