From 95dc78a61f71231aebd5e7776e2f172cb6f6c8ab Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 26 Dec 2022 23:27:12 +1100 Subject: [PATCH] [Testing] Fix docker build (#4109) * Test fix for ongoing CI issues (cherry picked from commit 3bf5492cb645ff967ad943e2f02f5f8a3f043f67) * Run docker test on PR (temporarily) * Add token to unit testing env * Add github token to env file * Fix for github token * Ignore blank tokens * Don't run on PR --- .github/workflows/docker.yaml | 5 +++++ InvenTree/plugin/base/integration/mixins.py | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 5498d69606..08f93a95a8 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -21,6 +21,10 @@ on: branches: - 'master' + # pull_request: + # branches: + # - 'master' + jobs: # Build the docker image @@ -70,6 +74,7 @@ jobs: test -f data/secret_key.txt - name: Run Unit Tests run: | + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> docker.dev.env docker-compose run inventree-dev-server invoke test --disable-pty docker-compose down - name: Set up QEMU diff --git a/InvenTree/plugin/base/integration/mixins.py b/InvenTree/plugin/base/integration/mixins.py index 313f7cc56c..232394ca3d 100644 --- a/InvenTree/plugin/base/integration/mixins.py +++ b/InvenTree/plugin/base/integration/mixins.py @@ -537,8 +537,11 @@ class APICallMixin: headers = {'Content-Type': 'application/json'} if getattr(self, 'API_TOKEN_SETTING'): token = self.get_setting(self.API_TOKEN_SETTING) - headers[self.API_TOKEN] = token - headers['Authorization'] = f"{self.API_TOKEN} {token}" + + if token: + headers[self.API_TOKEN] = token + headers['Authorization'] = f"{self.API_TOKEN} {token}" + return headers def api_build_url_args(self, arguments: dict) -> str: