diff --git a/.codegenignore b/.codegenignore index c11eabc8..9924abf2 100644 --- a/.codegenignore +++ b/.codegenignore @@ -4,3 +4,4 @@ docker-compose.yml DockerFile tests/** +cleanupSite.sh \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e23c007e..e6cacf42 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -1,14 +1,11 @@ name: python on: - push: - branches: [ "**" ] pull_request: branches: [ "main" ] jobs: build: - runs-on: ubuntu-latest steps: @@ -23,10 +20,63 @@ jobs: pip install -r requirements.txt pip install -r test-requirements.txt - - name: Tests - run: pytest tests/ - env: - BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }} - BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }} - SUBDOMAIN: ${{ secrets.SUBDOMAIN }} - DOMAIN: ${{ secrets.DOMAIN }} + cleanup_site_before_tests: + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v3 + + - name: Cleanup Site + run: ./cleanupSite.sh + env: + BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }} + BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }} + SUBDOMAIN: ${{ secrets.SUBDOMAIN }} + DOMAIN: ${{ secrets.DOMAIN }} + + - name: Wait 10 seconds to allow site be cleared + run: sleep 10 + + + run_tests: + runs-on: ubuntu-latest + needs: cleanup_site_before_tests + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v3 + with: + python-version: "3.11" + + - name: Install deps + run: | + pip install -r requirements.txt + pip install -r test-requirements.txt + + - name: Tests + run: pytest tests/ + env: + BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }} + BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }} + SUBDOMAIN: ${{ secrets.SUBDOMAIN }} + DOMAIN: ${{ secrets.DOMAIN }} + + cleanup_site_after_tests: + runs-on: ubuntu-latest + needs: run_tests + + steps: + - uses: actions/checkout@v3 + + - name: Cleanup Site + run: ./cleanupSite.sh + env: + BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }} + BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }} + SUBDOMAIN: ${{ secrets.SUBDOMAIN }} + DOMAIN: ${{ secrets.DOMAIN }} + + - name: Wait 10 seconds to allow site be cleared + run: sleep 10 diff --git a/.gitignore b/.gitignore index 0d20b648..818bebe0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.pyc +.env +.idea \ No newline at end of file diff --git a/cleanupSite.sh b/cleanupSite.sh new file mode 100755 index 00000000..66b889d9 --- /dev/null +++ b/cleanupSite.sh @@ -0,0 +1,6 @@ +auth=$(echo "$BASIC_AUTH_USERNAME":"$BASIC_AUTH_PASSWORD" | base64) + +curl --request POST \ + --url https://"$SUBDOMAIN"."$DOMAIN"/sites/clear_data.json?cleanup_scope=all \ + --header "Authorization: Basic $auth" \ + --header 'Content-Type: application/json' \ No newline at end of file