Skip to content

Commit f19e030

Browse files
committed
fix workflow
1 parent 931fdac commit f19e030

File tree

3 files changed

+46
-46
lines changed

3 files changed

+46
-46
lines changed

.github/workflows/verify-compile.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ jobs:
3232
sustechthesis.pdf
3333
public-test/*.pdf
3434
35-
# - name: Deploy PDF to latest branch
36-
# uses: peaceiris/actions-gh-pages@v3
37-
# if: github.ref == 'refs/heads/master'
38-
# with:
39-
# github_token: ${{ secrets.GITHUB_TOKEN }}
40-
# publish_dir: ./public-test
41-
# publish_branch: latest
42-
# force_orphan: true
43-
4435
sync:
4536
runs-on: ubuntu-latest
4637
name: Sync to other git service
@@ -52,18 +43,6 @@ jobs:
5243
# needs: build_latex
5344
steps:
5445

55-
# - name: Push to gitee
56-
# run: |
57-
# mkdir -p /tmp/tmp_push
58-
# cd /tmp/tmp_push
59-
# git clone --bare https://github.com/liziwl/sustech-master-thesis.git this_repo
60-
# cd this_repo
61-
# git push --force --mirror "https://${USER}:${PERSONAL_TOKEN}@${REPO_URL}"
62-
# env:
63-
# USER: ${{ secrets.GITEE_USER }}
64-
# PERSONAL_TOKEN: ${{ secrets.GITEE_PERSONAL_TOKEN }}
65-
# REPO_URL: "gitee.com/liziwl/sustech-master-thesis.git"
66-
6746
- name: Push to sustech-git
6847
run: |
6948
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)

test/test-files.py

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,62 @@ def rollback(filename, mode):
6161
shutil.copyfile(f'{filename}.lock', filename)
6262

6363

64+
def backup(filename, mode):
65+
if mode:
66+
# before change, backup
67+
try:
68+
shutil.copyfile(filename, f'{filename}.undo.bak')
69+
except:
70+
pass
71+
else:
72+
# after change, restore
73+
try:
74+
shutil.copyfile(f'{filename}.undo.bak', filename)
75+
os.remove(f'{filename}.undo.bak')
76+
except:
77+
pass
78+
79+
6480
if __name__ == "__main__":
6581
import argparse
6682
parser = argparse.ArgumentParser()
6783
parser.add_argument("--recipe", type=int, required=True, help='recipe value')
84+
parser.add_argument('--undo', action='store_true')
6885
args = parser.parse_args()
86+
TOBACKUP = not args.undo
6987

7088
if args.recipe == 1:
7189
# chinese
7290
filename = "sustechthesis-example.tex"
73-
change_line(filename,
74-
"documentclass.+{sustechthesis}",
75-
"documentclass[degree=master,language=chinese,cjk-font=external]{sustechthesis}"
76-
)
91+
backup(filename, TOBACKUP)
92+
if not args.undo:
93+
change_line(filename,
94+
"documentclass.+{sustechthesis}",
95+
"documentclass[degree=master,language=chinese,cjk-font=external]{sustechthesis}"
96+
)
7797
elif args.recipe == 2:
7898
# english
7999
filename = "sustechthesis-example.tex"
80-
change_line(filename,
81-
"documentclass.+{sustechthesis}",
82-
"documentclass[degree=master,language=english,cjk-font=external]{sustechthesis}"
83-
)
100+
backup(filename, TOBACKUP)
101+
if not args.undo:
102+
change_line(filename,
103+
"documentclass.+{sustechthesis}",
104+
"documentclass[degree=master,language=english,cjk-font=external]{sustechthesis}"
105+
)
84106
elif args.recipe == 3:
85107
# biber
86108
filename = "sustechthesis-example.tex"
87-
comment_line(filename, "bibliography{ref/refs}", True)
88-
comment_line(filename, "printbibliography", False)
109+
backup(filename, TOBACKUP)
110+
if not args.undo:
111+
comment_line(filename, "bibliography{ref/refs}", True)
112+
comment_line(filename, "printbibliography", False)
113+
89114
filename = "sustech-setup.tex"
90-
comment_line(filename, "{gbt7714}", True)
91-
comment_line(filename, "citestyle{super}", True)
92-
comment_line(filename, "citestyle{numbers}", True)
93-
comment_line(filename, "bibliographystyle{sustechthesis-numeric}", True)
94-
comment_line(filename, "{biblatex}", False)
95-
comment_line(filename, "addbibresource{ref/refs.bib}", False)
115+
backup(filename, TOBACKUP)
116+
if not args.undo:
117+
comment_line(filename, "{gbt7714}", True)
118+
comment_line(filename, "citestyle{super}", True)
119+
comment_line(filename, "citestyle{numbers}", True)
120+
comment_line(filename, "bibliographystyle{sustechthesis-numeric}", True)
121+
comment_line(filename, "{biblatex}", False)
122+
comment_line(filename, "addbibresource{ref/refs.bib}", False)

test/test.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,20 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
55
RT_DIR="$( dirname "${SCRIPT_DIR}" )"
66
mkdir "$RT_DIR/public-test"
77

8-
# 备份原文件
9-
cp "$RT_DIR/sustechthesis-example.tex" "$RT_DIR/sustechthesis-example.tex.bak"
10-
118
# 生成中文预览
12-
cp "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
139
python3 "$RT_DIR/test/test-files.py" --recipe 1
1410
make
1511
cp "$RT_DIR/sustechthesis-example.pdf" "$RT_DIR/public-test/sustechthesis-example-cn.pdf"
12+
python3 "$RT_DIR/test/test-files.py" --recipe 1 --undo
1613

1714
# 生成英文预览
18-
cp "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
1915
python3 "$RT_DIR/test/test-files.py" --recipe 2
2016
make
2117
cp "$RT_DIR/sustechthesis-example.pdf" "$RT_DIR/public-test/sustechthesis-example-en.pdf"
18+
python3 "$RT_DIR/test/test-files.py" --recipe 2 --undo
2219

2320
# 生成biber预览
24-
cp "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
2521
python3 "$RT_DIR/test/test-files.py" --recipe 3
2622
make
2723
cp "$RT_DIR/sustechthesis-example.pdf" "$RT_DIR/public-test/sustechthesis-example-biber.pdf"
28-
29-
# 恢复源文件
30-
mv "$RT_DIR/sustechthesis-example.tex.bak" "$RT_DIR/sustechthesis-example.tex"
24+
python3 "$RT_DIR/test/test-files.py" --recipe 3 --undo

0 commit comments

Comments
 (0)