From f2f5f6db75ed231f7d386773c70d02be7c63f18b Mon Sep 17 00:00:00 2001 From: hiranya911 Date: Thu, 6 Feb 2020 16:08:53 -0800 Subject: [PATCH] chore: Running integration tests in release workflow --- .../resources/integ-service-account.json.gpg | Bin 0 -> 1733 bytes .github/scripts/run_integration_tests.sh | 11 +++++++++ .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 22 ++++++++++-------- integration/test_db.py | 2 +- 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 .github/resources/integ-service-account.json.gpg create mode 100755 .github/scripts/run_integration_tests.sh diff --git a/.github/resources/integ-service-account.json.gpg b/.github/resources/integ-service-account.json.gpg new file mode 100644 index 0000000000000000000000000000000000000000..e8cc3e2a2a970b6760faceb0ff7dfc3e4b02c60a GIT binary patch literal 1733 zcmV;$20HnS4Fm}T0&*P1GU?%eegD$x0rvxBAXZGDSEYyg&@r!tuJO!^@&2Mg0RD-w z6$6e;;`CFWj*fn+wYp+93`zD7be^H9^(f2dArxBMIsVqnH^uk`NBpM}j)R?=LOWsA z{+*+Is!_mH0&L^@gva$WU4tSy{!^+>46sf3l~2(yGHLCQJ|AD}OSS4|w)W)bIhUCB ztLZxR_T>Ox?nQ%n2SuXok1L6Q?jrQ##qw?ASK7)@vt_ihr{>UJqi+)ws0`vx6lVaz zYoMV^widvCLEMCOzE9r4f`M#Cz#4ukZW(RbYSG4zyaS7o#kYgzHU2SEPW}TDgOeO$ zl8#OV2K4iNZ(_%sDt3-8G?e{}9)Xa63cE<5Tw~PUBhHb%f%Wp+7@Dii4KH~>ThXnc zJU+i2l19mPJ*o^DiA1mUbL4eB> zbfqZwFA9iW9)@X5^Jg;FmKH1LyrWqA*+tn$T-+S{Q!Ba4sb3{w26;5ycQyh=djxuG zE6Ef&YBF(Bdd_s{DEg>abVPH z6sfGhfLXxrTgj3Towx+c#p!H^NDd+(me+3C^t?B9kvUgNYxtM|xwc~5A3rV?MQ&Eb zRJ)mm($0#cd@i+T7wA;@d~q4WBv2zt(~SwCC&t<(Qzk>wvIas=r{SY@FlV!7%Y4X|e=JDOGfN84Xw7mlf9b{Z_{P(a;fJd&Ex zPE;unRrc%Lt6Yl#y!I` zW#bH&1CfNm3=Yxg&2XrnR$`$>mqEN6koziF5@98L^u}ja`*?#L9DqbkUsSVDO%mCg zyP&~Gf!nBhwHZTdZJZ=?(OfE%qT3Og6Pj0p(`{TM5&%c%Sp%Ly^p!vvKI|2`DN^t$ z+dont3_<4G_ds{)3CY0N32M6o8Nw=bodIN2N}2j6Kx>s0I%&=ci z8<<`m=?L9(VxxCHhes%UrPSTNQG&?qWdm{1;3a=FlA-^@>_1LqL4PsLKUIJ|lW}}ll^Rmr+`u^00-Zu3=0MK{X7=wW1xG9v zb>+uzSLWHC`%$|q#}_OwBP?rUGXCC>US#9h1-dE_KdPv%`8PBHTXX2${J{nG-7ZR7 z)j;WYkbTKBD-I^zOeBUw_AQ~!0`Ql&jp&}z(t&1V;13U#S4w>IC{WpQqf+-0w%_krosfryd7nMa+kp*`jl7_Q}9BY)T)sl`80~A!l zY=Kfl2&-TmHbwDIP%GrpRKMWoYsK z6~5b^5HMXvSl{rRG8_Innc{l2^8=++T>ul8K#~j(O_2?|&4mMfRkS+zMy2vVS}Cb;C8Qbj zh_XDiovWpqGvdj(vC6e_XKoj<`4>%Sm#lPtm?g(B1X|F~Ecq?+-dLoI<(r(K|0;(F z-GjL5-xIv&u}KCiyG&3X*caBWCC>sfo`m7udmy%Fq=do+s!GWP52a-~I()x-5i@;$ zKiD+X_ujNViv(}lsFTk0pW{G7J$y)Z-62(VZ^ literal 0 HcmV?d00001 diff --git a/.github/scripts/run_integration_tests.sh b/.github/scripts/run_integration_tests.sh new file mode 100755 index 000000000..060c5ba9f --- /dev/null +++ b/.github/scripts/run_integration_tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e +set -u + +gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" \ + --output integ-service-account.json .github/resources/integ-service-account.json.gpg + +echo "${FIREBASE_API_KEY}" > integ-api-key.txt + +pytest integration/ --cert integ-service-account.json --apikey integ-api-key.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 976767d64..5a952418c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Continuous Integration -on: [push, pull_request] +on: push jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6111dd7f1..df6183952 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,11 +15,10 @@ name: Release on: - # Only run the workflow when a PR is closed, or when a developer explicitly requests + # Only run the workflow when a PR is updated or when a developer explicitly requests # a build by sending a 'firebase_build' event. pull_request: - types: - - closed + types: [opened, synchronize, closed] repository_dispatch: types: @@ -27,10 +26,9 @@ on: jobs: stage_release: - # If triggered by a PR it must be merged and contain the label 'release:build'. + # If triggered by a PR it must contain the label 'release:build'. if: github.event.action == 'firebase_build' || - (github.event.pull_request.merged && - contains(github.event.pull_request.labels.*.name, 'release:build')) + contains(github.event.pull_request.labels.*.name, 'release:build') runs-on: ubuntu-latest @@ -53,10 +51,14 @@ jobs: pip install -r requirements.txt pip install wheel - - name: Run tests - run: | - pytest - echo "Running integration tests" + - name: Run unit tests + run: pytest + + - name: Run integration tests + run: ./.github/scripts/run_integration_tests.sh + env: + FIREBASE_SERVICE_ACCT_KEY: ${{ secrets.FIREBASE_SERVICE_ACCT_KEY }} + FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }} - name: Package release artifacts run: python setup.py bdist_wheel bdist_egg diff --git a/integration/test_db.py b/integration/test_db.py index 7a73ea3ad..c448436d6 100644 --- a/integration/test_db.py +++ b/integration/test_db.py @@ -55,7 +55,7 @@ def update_rules(app): with open(testutils.resource_filename('dinosaurs_index.json')) as rules_file: new_rules = json.load(rules_file) client = db.reference('', app)._client - rules = client.body('get', '/.settings/rules.json') + rules = client.body('get', '/.settings/rules.json', params='format=strict') existing = rules.get('rules') if existing != new_rules: rules['rules'] = new_rules