|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + pull_request: |
| 6 | + schedule: |
| 7 | + # NOTE: We run this weekly at 1 am UTC on every Saturday |
| 8 | + - cron: '0 1 * * 6' |
| 9 | + |
| 10 | +jobs: |
| 11 | + # This is based on this workflow, with an additional test env setup method |
| 12 | + # StackStorm-Exchange/ci/.github/workflows/pack-build_and_test.yaml@master |
| 13 | + |
| 14 | + build_and_test: |
| 15 | + runs-on: ubuntu-22.04 |
| 16 | + name: 'Build and Test / Python ${{ matrix.python-version-short }}' |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - python-version-short: "3.9" |
| 21 | + python-version: 3.9.21 |
| 22 | + consul-version: "1.22.7-1" |
| 23 | + vault-version: "2.0.0-1" |
| 24 | + hvac-gh-tag: "v2.4.0" |
| 25 | + - python-version-short: "3.10" |
| 26 | + python-version: 3.10.16 |
| 27 | + consul-version: "1.22.7-1" |
| 28 | + vault-version: "2.0.0-1" |
| 29 | + hvac-gh-tag: "v2.4.0" |
| 30 | + - python-version-short: "3.11" |
| 31 | + python-version: 3.11.11 |
| 32 | + consul-version: "1.22.7-1" |
| 33 | + vault-version: "2.0.0-1" |
| 34 | + hvac-gh-tag: "v2.4.0" |
| 35 | + steps: |
| 36 | + - name: Checkout Pack Repo and CI Repos |
| 37 | + uses: StackStorm-Exchange/ci/.github/actions/checkout@master |
| 38 | + |
| 39 | + - name: Checkout github.com/hvac/hvac |
| 40 | + uses: actions/checkout@v2 |
| 41 | + with: |
| 42 | + path: hvac |
| 43 | + repository: hvac/hvac |
| 44 | + # main = the release branch; devel = the active development branch |
| 45 | + ref: ${{ matrix.hvac-gh-tag }} |
| 46 | + fetch-depth: 0 |
| 47 | + |
| 48 | + - name: Install APT Dependencies |
| 49 | + uses: StackStorm-Exchange/ci/.github/actions/apt-dependencies@master |
| 50 | + with: |
| 51 | + cache-version: v0 |
| 52 | + |
| 53 | + - name: Install Python Dependencies |
| 54 | + uses: StackStorm-Exchange/ci/.github/actions/py-dependencies@master |
| 55 | + with: |
| 56 | + cache-version: v0 |
| 57 | + python-version: ${{ matrix.python-version }} |
| 58 | + |
| 59 | + # task copied (Apache 2.0 License) from |
| 60 | + # github.com/hvac/hvac .github/workflows/lint-and-test.yml |
| 61 | + - name: Install Vault and Consul (for integration tests) |
| 62 | + working-directory: pack |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/hashicorp.gpg |
| 66 | + echo "deb [arch=amd64, signed-by=/etc/apt/trusted.gpg.d/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \ |
| 67 | + | sudo tee /etc/apt/sources.list.d/hashicorp.list |
| 68 | + |
| 69 | + sudo apt update \ |
| 70 | + -o Dir::Etc::sourceparts="-" \ |
| 71 | + -o APT::Get::List-Cleanup="0" \ |
| 72 | + -o Dir::Etc::sourcelist="sources.list.d/hashicorp.list" |
| 73 | + |
| 74 | + sudo apt install consul=${{ matrix.consul-version }} vault=${{ matrix.vault-version }} |
| 75 | + |
| 76 | + # We disble cap_ipc_lock here as its generally incompatabile with GitHub |
| 77 | + # Actions' runtime environments. |
| 78 | + sudo setcap cap_ipc_lock= /usr/bin/vault |
| 79 | + |
| 80 | + # Consul needs to be explicitly configured to start in the CI/CD environment. |
| 81 | + sudo mkdir -p /srv/consul && sudo chown -R consul:consul /srv/consul |
| 82 | + sudo tee /etc/consul.d/consul.hcl >/dev/null <<EOF |
| 83 | + enable_debug = false |
| 84 | + datacenter = "cicd" |
| 85 | + data_dir = "/srv/consul" |
| 86 | + ui_config{ |
| 87 | + enabled = false |
| 88 | + } |
| 89 | + server = true |
| 90 | + bind_addr = "127.0.0.1" |
| 91 | + client_addr = "127.0.0.1" |
| 92 | + advertise_addr = "127.0.0.1" |
| 93 | + retry_join = ["localhost"] |
| 94 | + bootstrap_expect = 0 |
| 95 | + encrypt = "katpv2wgyY5Za8bGAHh7+URaeLJWh4g+gK0GBjmvQXA=" |
| 96 | + EOF |
| 97 | + sudo systemctl restart consul |
| 98 | + sudo systemctl restart vault |
| 99 | + |
| 100 | + - name: Setup hvac symlinks |
| 101 | + shell: bash |
| 102 | + env: |
| 103 | + HVAC_DIR: ${{ github.workspace }}/hvac |
| 104 | + run: | |
| 105 | + # using symlinks allows us to import tests.utils.* without adding |
| 106 | + # the rest of the hvac tests. tests.utils also uses config_files, |
| 107 | + # so make that available too. |
| 108 | + set -eux |
| 109 | + for x in utils config_files; do |
| 110 | + rm -f ${ROOT_DIR}/tests/${x} |
| 111 | + # relative (-r) allows the symlink to work in vagrant |
| 112 | + ln -rs ${HVAC_DIR}/tests/${x} ${ROOT_DIR}/tests/${x} |
| 113 | + ls -ld ${ROOT_DIR}/tests/${x} |
| 114 | + done |
| 115 | + |
| 116 | + - name: Run pack tests |
| 117 | + uses: StackStorm-Exchange/ci/.github/actions/test@master |
| 118 | + with: |
| 119 | + enable-common-libs: false |
| 120 | + |
| 121 | + services: |
| 122 | + mongo: |
| 123 | + image: mongo:7.0 |
| 124 | + ports: |
| 125 | + - 27017:27017 |
| 126 | + rabbitmq: |
| 127 | + image: rabbitmq:3 |
| 128 | + ports: |
| 129 | + - 5672:5672 |
| 130 | + #redis: |
| 131 | + # image: redis |
| 132 | + # ports: |
| 133 | + # - 6379:6379 |
0 commit comments