Skip to content

CI

CI #92

name: CI
on:
workflow_call:
pull_request:
schedule:
# NOTE: We run this weekly at 1 am UTC on every Saturday
- cron: '0 1 * * 6'
jobs:
# This is based on this workflow, with an additional test env setup method
# StackStorm-Exchange/ci/.github/workflows/pack-build_and_test.yaml@master
build_and_test:
runs-on: ubuntu-20.04
name: 'Build and Test / Python ${{ matrix.python-version-short }}'
strategy:
matrix:
include:
- python-version-short: "3.8"
python-version: 3.8.17
vault-version: "1.12.5-1"
hvac-gh-tag: "v1.1.1"
steps:
- name: Checkout Pack Repo and CI Repos
uses: StackStorm-Exchange/ci/.github/actions/checkout@master
- name: Checkout github.com/hvac/hvac
uses: actions/checkout@v2
with:
path: hvac
repository: hvac/hvac
# main = the release branch; devel = the active development branch
ref: ${{ matrix.hvac-gh-tag }}
fetch-depth: 0
- name: Install APT Dependencies
uses: StackStorm-Exchange/ci/.github/actions/apt-dependencies@master
with:
cache-version: v0
- name: Install Python Dependencies
uses: StackStorm-Exchange/ci/.github/actions/py-dependencies@master
with:
cache-version: v0
python-version: ${{ matrix.python-version }}
# task copied (Apache 2.0 License) from
# github.com/hvac/hvac .github/workflows/lint-and-test.yml
- name: Install Vault and Consul (for integration tests)
working-directory: pack
shell: bash
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/hashicorp.gpg
echo "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update \
-o Dir::Etc::sourceparts="-" \
-o APT::Get::List-Cleanup="0" \
-o Dir::Etc::sourcelist="sources.list.d/hashicorp.list"
sudo apt install consul vault=${{ matrix.vault-version }}
# We disble cap_ipc_lock here as its generally incompatabile with GitHub
# Actions' runtime environments.
sudo setcap cap_ipc_lock= /usr/bin/vault
- name: Setup hvac symlinks
shell: bash
env:
HVAC_DIR: ${{ github.workspace }}/hvac
run: |
# using symlinks allows us to import tests.utils.* without adding
# the rest of the hvac tests. tests.utils also uses config_files,
# so make that available too.
set -eux
for x in utils config_files; do
rm -f ${ROOT_DIR}/tests/${x}
# relative (-r) allows the symlink to work in vagrant
ln -rs ${HVAC_DIR}/tests/${x} ${ROOT_DIR}/tests/${x}
ls -ld ${ROOT_DIR}/tests/${x}
done
- name: Update virtualenv activate script
# This works around an infinite recursion error with newer requests+ssl+eventlet.
# eventlet monkey_patch as early as possible (has to be in activate as nosetests gets reinstalled during test phase)
# See: https://github.com/StackStorm-Exchange/stackstorm-vault/pull/23
run: |
echo "grep -q monkey_patch ${VIRTUALENV_DIR}/bin/nosetests || sed -i -e '/^import re$/i from st2common.util.monkey_patch import monkey_patch\nmonkey_patch()\n' ${VIRTUALENV_DIR}/bin/nosetests" >> ${VIRTUALENV_DIR}/bin/activate
echo "grep -q pyopenssl\\.inject ${VIRTUALENV_DIR}/bin/nosetests || sed -i -e '/^import re$/i from urllib3.contrib import pyopenssl\npyopenssl.inject_into_urllib3()\n' ${VIRTUALENV_DIR}/bin/nosetests" >> ${VIRTUALENV_DIR}/bin/activate
- name: Run pack tests
uses: StackStorm-Exchange/ci/.github/actions/test@master
with:
enable-common-libs: false
services:
mongo:
image: mongo:4.4
ports:
- 27017:27017
rabbitmq:
image: rabbitmq:3
ports:
- 5672:5672
#redis:
# image: redis
# ports:
# - 6379:6379