Spaces:
Configuration error
Configuration error
Add CI/CD, deploy, and tests files for feature branch
Browse files- .github/workflows/ci-cd.yml +22 -2
- .github/workflows/deploy.yml +39 -17
- tests/__init__.py +0 -0
- tests/test_app.py +8 -0
.github/workflows/ci-cd.yml
CHANGED
@@ -3,7 +3,7 @@ name: CI/CD Pipeline
|
|
3 |
on:
|
4 |
push:
|
5 |
branches:
|
6 |
-
- feature
|
7 |
- develop
|
8 |
- main
|
9 |
|
@@ -28,8 +28,18 @@ jobs:
|
|
28 |
merge-to-develop:
|
29 |
needs: build
|
30 |
runs-on: ubuntu-latest
|
31 |
-
if: github.ref
|
32 |
steps:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
- name: Merge feature branch to develop
|
34 |
run: |
|
35 |
git fetch origin
|
@@ -42,6 +52,16 @@ jobs:
|
|
42 |
runs-on: ubuntu-latest
|
43 |
if: github.ref == 'refs/heads/develop'
|
44 |
steps:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
- name: Merge develop branch to main
|
46 |
run: |
|
47 |
git fetch origin
|
|
|
3 |
on:
|
4 |
push:
|
5 |
branches:
|
6 |
+
- "feature/**"
|
7 |
- develop
|
8 |
- main
|
9 |
|
|
|
28 |
merge-to-develop:
|
29 |
needs: build
|
30 |
runs-on: ubuntu-latest
|
31 |
+
if: startsWith(github.ref, 'refs/heads/feature/')
|
32 |
steps:
|
33 |
+
- name: Checkout Repository
|
34 |
+
uses: actions/checkout@v3
|
35 |
+
with:
|
36 |
+
fetch-depth: 0
|
37 |
+
|
38 |
+
- name: Set up Git
|
39 |
+
run: |
|
40 |
+
git config --global user.name "GitHub Actions"
|
41 |
+
git config --global user.email "[email protected]"
|
42 |
+
|
43 |
- name: Merge feature branch to develop
|
44 |
run: |
|
45 |
git fetch origin
|
|
|
52 |
runs-on: ubuntu-latest
|
53 |
if: github.ref == 'refs/heads/develop'
|
54 |
steps:
|
55 |
+
- name: Checkout Repository
|
56 |
+
uses: actions/checkout@v3
|
57 |
+
with:
|
58 |
+
fetch-depth: 0
|
59 |
+
|
60 |
+
- name: Set up Git
|
61 |
+
run: |
|
62 |
+
git config --global user.name "GitHub Actions"
|
63 |
+
git config --global user.email "[email protected]"
|
64 |
+
|
65 |
- name: Merge develop branch to main
|
66 |
run: |
|
67 |
git fetch origin
|
.github/workflows/deploy.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
name: Deploy to Hugging Face
|
2 |
|
3 |
on:
|
4 |
push:
|
@@ -10,19 +10,41 @@ jobs:
|
|
10 |
runs-on: ubuntu-latest
|
11 |
|
12 |
steps:
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Deploy to Hugging Face Spaces
|
2 |
|
3 |
on:
|
4 |
push:
|
|
|
10 |
runs-on: ubuntu-latest
|
11 |
|
12 |
steps:
|
13 |
+
- name: Checkout code
|
14 |
+
uses: actions/checkout@v3
|
15 |
+
with:
|
16 |
+
fetch-depth: 0
|
17 |
+
|
18 |
+
- name: Set up Python
|
19 |
+
uses: actions/setup-python@v3
|
20 |
+
with:
|
21 |
+
python-version: 3.9
|
22 |
+
|
23 |
+
- name: Install Hugging Face CLI
|
24 |
+
run: |
|
25 |
+
pip install huggingface_hub
|
26 |
+
mkdir -p ~/.huggingface
|
27 |
+
echo ${{ secrets.HF_TOKEN }} > ~/.huggingface/token
|
28 |
+
huggingface-cli login --token ${{ secrets.HF_TOKEN }}
|
29 |
+
|
30 |
+
- name: Configure Git for Hugging Face
|
31 |
+
run: |
|
32 |
+
git config --global user.name "nkofficial-1005"
|
33 |
+
git config --global user.email "[email protected]"
|
34 |
+
git remote add hf https://huggingface.co/spaces/kohlin/nlp-project || true
|
35 |
+
git remote set-url hf https://kohlin:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/kohlin/nlp-project
|
36 |
+
|
37 |
+
- name: Set up Git LFS (if needed)
|
38 |
+
run: |
|
39 |
+
git lfs install
|
40 |
+
git lfs pull hf main || true
|
41 |
+
|
42 |
+
- name: Pull latest changes from Hugging Face (merge histories)
|
43 |
+
run: |
|
44 |
+
git pull hf main --allow-unrelated-histories --no-rebase || true
|
45 |
+
|
46 |
+
- name: Push latest code to Hugging Face
|
47 |
+
run: |
|
48 |
+
git push hf main --force-with-lease
|
49 |
+
env:
|
50 |
+
HUGGINGFACE_TOKEN: ${{ secrets.HF_TOKEN }}
|
tests/__init__.py
ADDED
File without changes
|
tests/test_app.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import unittest
|
2 |
+
|
3 |
+
class TestApp(unittest.TestCase):
|
4 |
+
def test_sample(self):
|
5 |
+
self.assertEqual(1 + 1, 2)
|
6 |
+
|
7 |
+
if __name__ == "__main__":
|
8 |
+
unittest.main()
|