Skip to content

Update release.yml (#92) #159

Update release.yml (#92)

Update release.yml (#92) #159

name: "PR Acceptance Test"
on:
push:
workflow_dispatch:
workflow_call:
secrets:
LITMUS_CLIENT_ID:
required: true
LITMUS_CLIENT_SECRET:
required: true
LITMUS_CID:
required: true
LINUX_SENSOR_VERSION:
required: true
pull_request_target:
types: [ labeled ]
paths:
- 'lib/**'
- 'manifests/**'
- '.github/workflows/pr_acceptance_test.yml'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
setup_matrix:
if: |
(github.event_name == 'pull_request_target' &&
github.event.label.name == 'ok-to-test') ||
contains(fromJson('["push", "workflow_dispatch", "schedule"]'), github.event_name)
name: "Setup Test Matrix"
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
ref: ${{ steps.git-vars.outputs.ref }}
repository: ${{ steps.git-vars.outputs.repository }}
steps:
- name: Checkout Source
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Setup git vars
id: git-vars
env:
REF: ${{github.event.pull_request.head.sha}}
REPOSITORY: ${{github.event.pull_request.head.repo.full_name}}
run: |
echo ::set-output name=ref::${REF}
echo ::set-output name=repository::${REPOSITORY}
- name: Print git vars
run: |
echo ${{ steps.git-vars.outputs.ref}}
echo ${{ steps.git-vars.outputs.repository}}
- name: Activate Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
bundler-cache: true
- name: Print bundle environment
run: |
bundle env
- name: Install dependencies
run: |
pip install -r ./.github/workflows/files/requirements.txt
- name: Setup Acceptance Test Matrix
id: get-matrix
run: |
python ./.github/workflows/files/generate_matrix.py -g linux
- name: Print matrix JSON
run: |
echo ${{ steps.get-matrix.outputs.matrix }}
Acceptance:
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
needs:
- setup_matrix
runs-on: ${{ matrix.platforms.os }}
strategy:
fail-fast: false
matrix:
platforms: ${{ fromJson(needs.setup_matrix.outputs.matrix).platforms }}
collection: ${{ fromJson(needs.setup_matrix.outputs.matrix).collections }}
steps:
- run: |
echo 'image=${{ matrix.platforms.image }}'
echo 'collection=${{ matrix.collection }}'
echo 'label=${{ matrix.platforms.label }}'
echo 'provider=${{ matrix.platforms.provider }}'
echo 'os=${{ matrix.os }}'
- name: Print git vars
run: |
echo ${{needs.setup_matrix.outputs.ref}}
echo ${{needs.setup_matrix.outputs.repository}}
- name: Checkout Source
uses: actions/checkout@v2
with:
ref: ${{needs.setup_matrix.outputs.ref}}
repository: ${{needs.setup_matrix.outputs.repository}}
- name: Cache Vagrant boxes
if: ${{ matrix.platforms.provider == 'vagrant' }}
uses: actions/cache@v2
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('./.github/workflows/pr_acceptance_test.yml') }}
restore-keys: |
${{ runner.os }}-vagrant-
- name: Activate Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
bundler-cache: true
- name: Print bundle environment
run: |
bundle env
- name: Provision test environment
run: |
CI=true bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
if [ -f 'spec/fixtures/litmus_inventory.yaml' ];
then
FILE='spec/fixtures/litmus_inventory.yaml'
elif [ -f 'inventory.yaml' ];
then
FILE='inventory.yaml'
fi
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
- name: Install agent
run: |
CI=true bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
- name: Install module
run: |
CI=true bundle exec rake 'litmus:install_module'
- name: Run acceptance tests
env:
FALCON_CLIENT_ID: ${{ secrets.LITMUS_CLIENT_ID }}
FALCON_CLIENT_SECRET: ${{ secrets.LITMUS_CLIENT_SECRET }}
FALCON_CID: ${{ secrets.LITMUS_CID }}
LINUX_SENSOR_VERSION: ${{ secrets.LINUX_SENSOR_VERSION }}
DEBUG: true
run: |
CI=true DEBUG=true bundle exec rake 'litmus:acceptance:parallel'
- name: Remove test environment
if: ${{ always() }}
continue-on-error: true
run: |
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
CI=true bundle exec rake 'litmus:tear_down'
fi