Merge pull request #2128 from gravitl/GRA-1253-test-automation

Gra 1253 test automation
This commit is contained in:
Alex Feiszli 2023-03-29 14:10:19 -04:00 committed by GitHub
commit 1def9d8422
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 96 additions and 0 deletions

58
.github/workflows/branchtest.yml vendored Normal file
View file

@ -0,0 +1,58 @@
name: Deploy and Test Branch
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
branches: [develop]
jobs:
skip-check:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- id: skip
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: 'always'
getbranch:
runs-on: ubuntu-latest
needs: skip-check
if: ${{ needs.skip-check.outputs.skip != 'true' }}
outputs:
netclientbranch: ${{ steps.checkbranch.outputs.netclientbranch }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
repository: gravitl/netclient
ref: develop
- name: check if branch exists
id: checkbranch
run: |
if git show-ref ${{ github.head_ref}}; then
echo branch exists
echo "netclientbranch=${{ github.head_ref }}" >> $GITHUB_OUTPUT
else
echo branch does not exist
echo "netclientbranch=develop" >> $GITHUB_OUTPUT
fi
terraform:
needs: getbranch
uses: gravitl/devops/.github/workflows/terraform.yml@master
with:
netmakerbranch: ${{ github.head_ref }}
netclientbranch: ${{ needs.getbranch.outputs.netclientbranch }}
secrets: inherit
testbranch:
needs: [getbranch, terraform]
uses: gravitl/devops/.github/workflows/branchtest.yml@master
with:
tag: ${{ github.run_id }}-${{ github.run_attempt }}
network: terraform
secrets: inherit

38
.github/workflows/deletedroplets.yml vendored Normal file
View file

@ -0,0 +1,38 @@
name: Delete Droplets
on:
workflows_run:
workflows: [Run All Test on Branch]
types:
- completed
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: delete droplets
run: |
sleep 15m
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
TAG: ${{ github.event.workflow_run.run_id }}-${{ github.event.workflow_run.run_attempt }}
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: delete droplets
run: |
sleep 6h
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/droplets?tag_name=$TAG"
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
TAG: ${{ github.event.workflow_run.run_id }}-${{ github.event.workflow_run.run_attempt }}