diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..0c9b7871 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +--- +name: pytest + +on: + pull_request: + branches: ['main'] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Set up Python environment + uses: actions/setup-python@v5 + + - name: Install dependencies + run: | + pip install pyaml pytest + + - name: Run tests + run: | + pytest + env: + GH_TOKEN: ${{ github.token }} diff --git a/gateway/test_gateway.py b/gateway/test_gateway.py index 74badb76..885e8f04 100644 --- a/gateway/test_gateway.py +++ b/gateway/test_gateway.py @@ -38,7 +38,7 @@ def test_update_refs(): }, "dorny/paths-filter": { "0bc4621a3135347011ad047f9ecf449bf72ce2bd": { - "expires_at": calculate_expiry() + "expires_at": calculate_expiry(12) }, "de90cc6fb38fc0963ad72b210f1f284cd68cea36": { "expires_at": datetime.date(2100, 1, 1), diff --git a/stash/restore/test_get_stash.py b/stash/restore/test_get_stash.py index d638b0ba..c8e1a575 100644 --- a/stash/restore/test_get_stash.py +++ b/stash/restore/test_get_stash.py @@ -14,6 +14,7 @@ import unittest import json +import os from get_stash import ensure_json, gh_api, jq @@ -23,7 +24,8 @@ def test_jq(self): self.assertEqual(jq('{"a": 1}', ".a", ["-j"]).stdout, "1") def test_jq_file(self): - self.assertEqual(jq("test.json", ".a").stdout, "1\n") + this_dir = os.path.dirname(os.path.realpath(__file__)) + self.assertEqual(jq(this_dir + "/test.json", ".a").stdout, "1\n") def test_jq_error(self): with self.assertRaises(ValueError):