Spaces:
Sleeping
Sleeping
Merge pull request #2 from Badrivishal/test
Browse files- .github/workflows/hf_sync.yml +0 -20
- .github/workflows/test.yml +0 -15
- .github/workflows/test_sync.yml +64 -0
- test_hello.py +12 -0
.github/workflows/hf_sync.yml
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
name: Sync to Hugging Face hub
|
| 2 |
-
on:
|
| 3 |
-
push:
|
| 4 |
-
branches: [main]
|
| 5 |
-
|
| 6 |
-
# to run this workflow manually from the Actions tab
|
| 7 |
-
workflow_dispatch:
|
| 8 |
-
|
| 9 |
-
jobs:
|
| 10 |
-
sync-to-hub:
|
| 11 |
-
runs-on: ubuntu-latest
|
| 12 |
-
steps:
|
| 13 |
-
- uses: actions/checkout@v3
|
| 14 |
-
with:
|
| 15 |
-
fetch-depth: 0
|
| 16 |
-
lfs: true
|
| 17 |
-
- name: Push to hub
|
| 18 |
-
env:
|
| 19 |
-
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 20 |
-
run: git push https://bapaurana:$HF_TOKEN@huggingface.co/spaces/bapaurana/xkcd_finder main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/workflows/test.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
name: Test code
|
| 2 |
-
on:
|
| 3 |
-
push:
|
| 4 |
-
branches: [test]
|
| 5 |
-
|
| 6 |
-
jobs:
|
| 7 |
-
test-code:
|
| 8 |
-
runs-on: ubuntu-latest
|
| 9 |
-
steps:
|
| 10 |
-
- uses: actions/checkout@v3
|
| 11 |
-
with:
|
| 12 |
-
fetch-depth: 0
|
| 13 |
-
lfs: true
|
| 14 |
-
- name: Test code
|
| 15 |
-
run: pytest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/workflows/test_sync.yml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Test & Sync
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- '**'
|
| 7 |
+
pull_request:
|
| 8 |
+
branches:
|
| 9 |
+
- '**'
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
test-code:
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
steps:
|
| 15 |
+
- uses: actions/checkout@v3
|
| 16 |
+
with:
|
| 17 |
+
fetch-depth: 0
|
| 18 |
+
lfs: true
|
| 19 |
+
|
| 20 |
+
- uses: actions/setup-python@v5
|
| 21 |
+
with:
|
| 22 |
+
python-version: 3.11.5
|
| 23 |
+
|
| 24 |
+
- name: Install dependencies
|
| 25 |
+
run: pip install pytest && pip install -r requirements.txt
|
| 26 |
+
|
| 27 |
+
- name: Test code
|
| 28 |
+
id: test
|
| 29 |
+
continue-on-error: true
|
| 30 |
+
run: pytest
|
| 31 |
+
|
| 32 |
+
- name: Send test results to Discord (failed)
|
| 33 |
+
if: steps.test.outcome != 'success'
|
| 34 |
+
env:
|
| 35 |
+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
| 36 |
+
run: |
|
| 37 |
+
curl -X POST -H "Content-Type: application/json" \
|
| 38 |
+
-d "{\"content\": \"A new commit $GITHUB_SHA was pushed to $GITHUB_REF_NAME by $GITHUB_ACTOR. But the test has failed :sad:\"}" \
|
| 39 |
+
$DISCORD_WEBHOOK_URL
|
| 40 |
+
exit 1
|
| 41 |
+
|
| 42 |
+
- name: Send test results to Discord (success)
|
| 43 |
+
if: steps.test.outcome == 'success'
|
| 44 |
+
env:
|
| 45 |
+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
| 46 |
+
run: |
|
| 47 |
+
curl -X POST -H "Content-Type: application/json" \
|
| 48 |
+
-d "{\"content\": \"A new commit $GITHUB_SHA was pushed to $GITHUB_REF_NAME by $GITHUB_ACTOR. Tests have passed! :smile:\"}" \
|
| 49 |
+
$DISCORD_WEBHOOK_URL
|
| 50 |
+
exit 0
|
| 51 |
+
|
| 52 |
+
deploy:
|
| 53 |
+
needs: test-code
|
| 54 |
+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
| 55 |
+
runs-on: ubuntu-latest
|
| 56 |
+
steps:
|
| 57 |
+
- uses: actions/checkout@v3
|
| 58 |
+
with:
|
| 59 |
+
fetch-depth: 0
|
| 60 |
+
lfs: true
|
| 61 |
+
- name: Push to hub
|
| 62 |
+
env:
|
| 63 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 64 |
+
run: git push https://bapaurana:$HF_TOKEN@huggingface.co/spaces/bapaurana/xkcd_finder main
|
test_hello.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import unittest
|
| 2 |
+
|
| 3 |
+
class TestHello(unittest.TestCase):
|
| 4 |
+
def test_hello(self):
|
| 5 |
+
self.assertEqual(hello(), "Hello, World!")
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def hello():
|
| 9 |
+
return "Hello, World!"
|
| 10 |
+
|
| 11 |
+
if __name__ == "__main__":
|
| 12 |
+
unittest.main()
|