diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c5a9cf645..3cf61512ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000000..3dace9a486 --- /dev/null +++ b/azure-pipelines.yml @@ -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' diff --git a/ci/azure_install_macos.sh b/ci/azure_install_macos.sh new file mode 100755 index 0000000000..9260bd669c --- /dev/null +++ b/ci/azure_install_macos.sh @@ -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 diff --git a/ci/azure_mirror.sh b/ci/azure_mirror.sh new file mode 100755 index 0000000000..42ba1279af --- /dev/null +++ b/ci/azure_mirror.sh @@ -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