From e7c758f0cf108f017bb95ed120ffdcf7cc79787f Mon Sep 17 00:00:00 2001 From: Izaim Date: Sat, 29 Jun 2024 19:09:36 +0200 Subject: [PATCH 1/5] init testing --- .github/workflows/tests.yml | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..5d9a47c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,63 @@ +# use pytest-cov to see what percentage of the code is being covered by tests +# WARNING: this workflow will fail if any of the tests within it fail + +name: Test Coverage +permissions: read-all + +on: + push: + branches: + - main + - pipeline/* + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + + # Cancel in-progress runs when a new workflow with the same group name is triggered + cancel-in-progress: true + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + +jobs: + test-coverage: + runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest] + python-version: [3.12] + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 + + - name: upgrade pip + run: pip install --upgrade pip + + - name: Install CRIPT Python SDK + run: pip install -e . + + - name: Install requirements_dev.txt + run: pip install -r requirements_dev.txt + + - name: Retrieve Cognito Tokens from AWS Secrets Manager + run: | + echo "CRIPT_TOKEN=$(aws secretsmanager get-secret-value --secret-id Pipelines_CognitoAccessToken --query SecretString --output text)" >> $GITHUB_ENV + echo "CRIPT_STORAGE_TOKEN=$(aws secretsmanager get-secret-value --secret-id Pipelines_CognitoIdToken --query SecretString --output text)" >> $GITHUB_ENV + + - name: Test Coverage + + run: pytest --cov --cov-fail-under=85 + env: + CRIPT_HOST: https://lb-stage.mycriptapp.org/ + CRIPT_TOKEN: ${{ env.CRIPT_TOKEN }} + CRIPT_STORAGE_TOKEN: ${{ env.CRIPT_STORAGE_TOKEN }} + CRIPT_TESTS: True \ No newline at end of file From b83d63f7be5402911538d91aa13a7163c15e4e18 Mon Sep 17 00:00:00 2001 From: Ludwig Schneider Date: Mon, 8 Jul 2024 15:34:19 -0500 Subject: [PATCH 2/5] adjusting the tests to the actual part we are interested in --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d9a47c..4661500 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,7 +30,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [3.12] + python-version: [3.8, 3.12] steps: - uses: actions/checkout@v4 @@ -55,7 +55,7 @@ jobs: - name: Test Coverage - run: pytest --cov --cov-fail-under=85 + run: pytest tests/api_resources/test_cript.py env: CRIPT_HOST: https://lb-stage.mycriptapp.org/ CRIPT_TOKEN: ${{ env.CRIPT_TOKEN }} From 17d9ce2098bf5d7f6f9121dc4ed23779bad942ad Mon Sep 17 00:00:00 2001 From: Ludwig Schneider Date: Mon, 8 Jul 2024 15:36:50 -0500 Subject: [PATCH 3/5] fix typos --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4661500..33b37a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,7 @@ # use pytest-cov to see what percentage of the code is being covered by tests # WARNING: this workflow will fail if any of the tests within it fail -name: Test Coverage +name: Test Pytest permissions: read-all on: @@ -25,7 +25,7 @@ env: AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} jobs: - test-coverage: + test-pytest: runs-on: ubuntu-latest strategy: matrix: @@ -45,8 +45,8 @@ jobs: - name: Install CRIPT Python SDK run: pip install -e . - - name: Install requirements_dev.txt - run: pip install -r requirements_dev.txt + - name: Install requirements-dev.lock + run: pip install -r requirements-dev.lock - name: Retrieve Cognito Tokens from AWS Secrets Manager run: | From e594205cc022ba0bf9bc6c639874ffee5c30605c Mon Sep 17 00:00:00 2001 From: Ludwig Schneider Date: Mon, 8 Jul 2024 15:38:33 -0500 Subject: [PATCH 4/5] one last typo --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 33b37a0..fdd23fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,7 +53,7 @@ jobs: echo "CRIPT_TOKEN=$(aws secretsmanager get-secret-value --secret-id Pipelines_CognitoAccessToken --query SecretString --output text)" >> $GITHUB_ENV echo "CRIPT_STORAGE_TOKEN=$(aws secretsmanager get-secret-value --secret-id Pipelines_CognitoIdToken --query SecretString --output text)" >> $GITHUB_ENV - - name: Test Coverage + - name: Test Pytest run: pytest tests/api_resources/test_cript.py env: From d80744f3e14597be4b91a4b68b0325161d557635 Mon Sep 17 00:00:00 2001 From: Ludwig Schneider Date: Mon, 8 Jul 2024 15:40:59 -0500 Subject: [PATCH 5/5] adjust variable names --- .github/workflows/tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fdd23fc..3e9cc75 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,7 +57,6 @@ jobs: run: pytest tests/api_resources/test_cript.py env: - CRIPT_HOST: https://lb-stage.mycriptapp.org/ - CRIPT_TOKEN: ${{ env.CRIPT_TOKEN }} - CRIPT_STORAGE_TOKEN: ${{ env.CRIPT_STORAGE_TOKEN }} - CRIPT_TESTS: True \ No newline at end of file + CRIPT_BASE_URL: https://lb-stage.mycriptapp.org/ + CRIPT_API_KEY: ${{ env.CRIPT_TOKEN }} + CRIPT_STORAGE: ${{ env.CRIPT_STORAGE_TOKEN }}