Skip to content

Commit

Permalink
Setup GitHub actions (#617)
Browse files Browse the repository at this point in the history
* intial commit to test one job for Github actions

* fix envs

* exclude this branch while testing github actions

* Copy the travis CI scripts and re-use for github actions

* Overwite ruby with custom version. Add new checks in bash

* run the unit tests now that setup is complete

* fix old travis envs

* add in step to print the logs

* print logs on failure

* Change the env BUILD_TYPE to GITHUB_JOB

* Add in the linux integration steps and use the BUILD_TYPE vs the GITHUB_JOB env to id the build

* use proper syntax for assigning envs via github actions

* add docker integration tests

* add and enable docker-compose COMPOSE_INTERACTIVE_NO_CLI for CI

* Add the docker-compose setup script as the built-on github action docker-compose is not working

* fix bash check for platform and build_type

* add option to docker-compose to hopefully remove error on Github actions

* Add and test out macos builds. Comment out linux builds for now as that's all working fine

* For mac builds, use the tar.gz openstudio files as mac 10.15 is having errors trying to headless install the OpenStudio.dmg. Error msg: "Unable to create basic Accelerated OpenGL renderer."

* install core utils for macos for building nokogiri

* fix the tar

* fix the curl output file name of OpenStudio

* almost there. adding suffix

* Setup is now working for osx. update the test.sh for osx

* adding integration tests for macos

* Use one job to string together the build, unit, integration and finally uploading gem packages. This should save some time with the uploading as we don't have to call the setup.sh again

* fix yml

* change -uses to uses

* fixup mac export script

* export to non repo dir and then cp back to repo dir

* forgot to wrap var using bash

* Adding in all final steps for docker, linux and mac builds and publishing

* update push to docker hub

* clean up and another condition for docker hub uploads for good measure to prevent accidental uploads

* rename the github action file and add in checks for docker upload

* Run on push and pull_request events

* Restore the travis and appveyor CI jobs and fix export of osx on travis

* remove all travis scripts and travis.yaml. Disabled project on travis-ci.org
  • Loading branch information
tijcolem authored Jan 25, 2021
1 parent 4a38e0f commit f86d1ba
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 231 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/openstudio-server-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: openstudio-server

on: [push, pull_request]

# example of how to restrict to one branch and push event
#on:
# push:
# branches:
# - test_branch

env:
USE_TESTING_TIMEOUTS: "true"
OPENSTUDIO_VERSION: 3.1.0
OPENSTUDIO_VERSION_SHA: e165090621
OPENSTUDIO_VERSION_EXT: ""
DOCKER_COMPOSE_VERSION: 1.21.1
BUNDLE_WITHOUT: native_ext


jobs:
linux-test:
runs-on: ubuntu-18.04
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: setup
shell: bash
run: ./ci/github-actions/setup.sh
- name: unit-test
shell: bash
run: ./ci/github-actions/test.sh
env:
BUILD_TYPE: test
- name: integration
shell: bash
run: ./ci/github-actions/test.sh
env:
BUILD_TYPE: integration
- name: logs
shell: bash
run: ./ci/github-actions/print_logs.sh
- name: build gem package
if: ${{ success() }}
shell: bash
run: ./ci/github-actions/export_build_linux.sh
- name: upload gem package
if: ${{ success() }}
uses: actions/upload-artifact@v2
with:
name: openstudio-server-gems-linux
path: build/NREL/export/*.tar.gz
macos-test:
runs-on: macos-10.15
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: setup
shell: bash
run: ./ci/github-actions/setup.sh
- name: unit-test
shell: bash
run: ./ci/github-actions/test.sh
env:
BUILD_TYPE: test
- name: integration
shell: bash
run: ./ci/github-actions/test.sh
env:
BUILD_TYPE: integration
- name: logs
shell: bash
run: ./ci/github-actions/print_logs.sh
- name: build gem package
if: ${{ success() }}
shell: bash
run: ./ci/github-actions/export_build_osx.sh
- name: upload gem package
if: ${{ success() }}
uses: actions/upload-artifact@v2
with:
name: openstudio-server-gems-darwin
path: build/NREL/export/*.tar.gz
docker:
runs-on: ubuntu-18.04
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: setup
shell: bash
run: ./ci/github-actions/setup.sh
env:
BUILD_TYPE: docker
- name: docker
shell: bash
run: |
export OPENSTUDIO_TAG=develop
sed -i -E "s/.git//g" .dockerignore
docker volume create --name=osdata
docker images --all
docker --version
docker-compose --version
docker-compose -f docker-compose.test.yml pull
docker-compose -f docker-compose.test.yml build --build-arg OPENSTUDIO_VERSION=$OPENSTUDIO_TAG
docker-compose -f docker-compose.test.yml up -d
docker-compose exec -T web /usr/local/bin/run-server-tests
docker-compose stop
git checkout -- .dockerignore && git checkout -- Dockerfile
env:
CI: true
OS_SERVER_NUMBER_OF_WORKERS: 4
BUILD_TYPE: docker
COMPOSE_INTERACTIVE_NO_CLI: 1
- name: logs
shell: bash
run: ./ci/github-actions/print_logs.sh
- name: docker-upload
if: |
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/setup_github_actions'
shell: bash
run: ./docker/deployment/scripts/deploy_docker_github_actions.sh
env:
CI: true
BUILD_TYPE: docker
# On forked Pull Requests secrets will not be sent to the runner. See more info here:
# https://docs.github.com/en/actions/reference/encrypted-secrets
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
125 changes: 0 additions & 125 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion bin/resources/local/rspec_command
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ rspec_path = File.absolute_path(File.join(__FILE__, './../../../../gems/bin/rspe
::ENV['OS_SERVER_LOG_PATH'] = File.join(output_dir, 'logs', 'rails.log')
::ENV['RAILS_ENV'] = 'local-test'

#If this is a travis build and it's BUILD_TYPE=test we want to omit the openstudio_algo_spec.rb tests
#If this is a CI build (travis, github actions, etc..) and the BUILD_TYPE=test omit the openstudio_algo_spec.rb tests
if ENV['BUILD_TYPE'] == 'test'
sys_call = " \"#{ruby_exe}\" \"#{bundle_path}\" exec \"#{ruby_exe}\" \"#{rspec_path}\" --tag ~depends_r --tag ~depends_gecko --tag ~depends_resque --exclude-pattern "\
"\"**/models/cluster_spec.rb\" --exclude-pattern \"**/features/openstudio_algo_spec.rb\""
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions ci/github-actions/export_build_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# empty dir for export
mkdir -p $GITHUB_WORKSPACE/build/NREL/export
mkdir -p $HOME/build/NREL/export

export PATH="/usr/loca/bin/ruby:/usr/local/openstudio-${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}/bin:${PATH}"
export GEM_HOME="$GITHUB_WORKSPACE/gems"
export GEM_PATH="$GITHUB_WORKSPACE/gems:$GITHUB_WORKSPACE/gems/bundler/gems"
# Dir containing openstudio
export RUBYLIB="/usr/local/openstudio-${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}/Ruby"
export OPENSTUDIO_TEST_EXE="/usr/local/openstudio-${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}/bin/openstudio"
mongo_dir="/usr/bin"
/usr/local/ruby/bin/ruby "${GITHUB_WORKSPACE}/bin/openstudio_meta" install_gems --export="${HOME}/build/NREL/export"
oss_filename="OpenStudio-server-$(git -C "${GITHUB_WORKSPACE}" rev-parse --short=10 HEAD)-linux.tar.gz"
ls -al $HOME/build/NREL/export/
# Build the gems and output to tar gz file. You need to specify a dir outside of the repo to export or
# openstudio_meta will error. Then for sake of using relative dirs with GitHub upload-artifacts, cp the file to
# the repo working directory.
cp $HOME/build/NREL/export/$oss_filename $GITHUB_WORKSPACE/build/NREL/export/$oss_filename


17 changes: 17 additions & 0 deletions ci/github-actions/export_build_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#empty dir for export
mkdir -p $GITHUB_WORKSPACE/build/NREL/export
mkdir -p $HOME/build/NREL/export


export OS_NAME_WITH_PLUS=OpenStudio-${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}+${OPENSTUDIO_VERSION_SHA}-Darwin
export PATH="$GITHUB_WORKSPACE/gems/bin:/usr/local/ruby/bin:$HOME/$OS_NAME_WITH_PLUS/bin:$PATH"
export RUBYLIB="$HOME/$OS_NAME_WITH_PLUS/Ruby"
export GEM_HOME="$GITHUB_WORKSPACE/gems"
export GEM_PATH="$GITHUB_WORKSPACE/gems:$GITHUB_WORKSPACE/gems/bundler/gems"
oss_filename="OpenStudio-server-$(git -C "${GITHUB_WORKSPACE}" rev-parse --short=10 HEAD)-darwin.tar.gz"

# Build the gems and output to tar gz file. You need to specify a dir outside of the repo to export or
# openstudio_meta will error. Then for sake of using relative dirs with GitHub upload-artifacts, cp the file to
# the repo working directory.
/usr/local/ruby/bin/ruby "${GITHUB_WORKSPACE}/bin/openstudio_meta" install_gems --export="${HOME}/build/NREL/export"
cp $HOME/build/NREL/export/$oss_filename $GITHUB_WORKSPACE/build/NREL/export/$oss_filename
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions ci/travis/print_logs.sh → ci/github-actions/print_logs.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#!/usr/bin/env bash

echo "Current directory is $(pwd)"
# echo "tree: ${TRAVIS_BUILD_DIR}/spec"
# tree "${TRAVIS_BUILD_DIR}/spec"
# echo "tree: ${GITHUB_WORKSPACE}/spec"
# tree "${GITHUB_WORKSPACE}/spec"
echo "=== PRINTING ERROR LOG REPORTS ==="

shopt -s nullglob

echo "=== PRINTING spec/files/logs/* ==="
for F in "${TRAVIS_BUILD_DIR}/spec/files/logs/"*
for F in "${GITHUB_WORKSPACE}/spec/files/logs/"*
do
echo '======================================================'
echo $F
echo '======================================================'
# Limit the rate of printing the log (with pv) to keep travis happy. https://github.com/travis-ci/travis-ci/issues/6018
# Limit the rate of printing the log (with pv)
cat $F | pv -q -L 3k
echo
done

echo "=== PRINTING /spec/unit-test/logs/* ==="
for F in "${TRAVIS_BUILD_DIR}/spec/unit-test/logs/"*
for F in "${GITHUB_WORKSPACE}/spec/unit-test/logs/"*
do
echo '======================================================'
echo $F
echo '======================================================'
# Limit the rate of printing the log (with pv) to keep travis happy. https://github.com/travis-ci/travis-ci/issues/6018
# Limit the rate of printing the log (with pv)
cat $F | pv -q -L 3k
echo
done


echo "=== PRINTING /spec/unit-test/logs/rails.log/* ==="
for F in "${TRAVIS_BUILD_DIR}/spec/unit-test/logs/rails.log/"*
for F in "${GITHUB_WORKSPACE}/spec/unit-test/logs/rails.log/"*
do
echo '======================================================'
echo $F
echo '======================================================'
# Limit the rate of printing the log (with pv) to keep travis happy. https://github.com/travis-ci/travis-ci/issues/6018
# Limit the rate of printing the log (with pv)
cat $F | pv -q -L 3k
echo
done
Loading

0 comments on commit f86d1ba

Please sign in to comment.