BlueGit

timfa hfy-novels

Files

hfy-novels / blue-ci-cd.yml

blue-ci-cd.yml

blue-ci-cd.yml 2.7 KiB Download Raw
1# HFY-Novels — tests op elke branch; index verversen handmatig of via een
2# web-pipeline op de standaardbranch. BlueGit heeft geen cron: periodiek
3# bijwerken doe je door deze pipeline handmatig te starten (of via de API).
4#
5# Geen tags of releases in deze pipeline.
6
7stages: [test, index]
8
9workflow:
10 rules:
11 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
12 - if: $CI_PIPELINE_SOURCE == "web"
13 - if: $CI_COMMIT_BRANCH != ""
14
15.test_rules: &test_rules
16 rules:
17 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
18 - if: $CI_PIPELINE_SOURCE == "web"
19 - if: $CI_COMMIT_BRANCH != ""
20
21test:indexer:
22 stage: test
23 image: bluegit/python
24 interruptible: true
25 timeout: 15m
26 <<: *test_rules
27 script:
28 - export PYTHONPATH="$PWD"
29 - pip install -q -r requirements-indexer.txt
30 - python3 -m unittest discover -s indexer/tests -v
31 - python3 indexer/build_index.py --from-fixture testdata/posts.json --dest /tmp/hfy-index --full
32 - python3 -c "import json,pathlib; m=json.loads(pathlib.Path('/tmp/hfy-index/catalog-meta.json').read_text()); assert m['novelCount']==3"
33
34test:plugin:
35 stage: test
36 image: bluegit/node
37 interruptible: true
38 timeout: 15m
39 <<: *test_rules
40 script:
41 - node scripts/build-manifest.js
42 - node scripts/test-plugin.js
43
44test:plugin-live:
45 stage: test
46 image: bluegit/node
47 interruptible: true
48 timeout: 10m
49 allow_failure: true
50 needs: ["test:plugin"]
51 <<: *test_rules
52 variables:
53 HFY_LIVE: "1"
54 script:
55 - node scripts/build-manifest.js
56 - node scripts/test-plugin.js
57
58# Handmatig of via een web-pipeline op master. Schrijft een verse index naar
59# public/ als artifact. Pusht alleen terug als het geheim INDEX_PUSH_TOKEN
60# is gezet (een token met write_repository). CI_JOB_TOKEN kan niet pushen.
61update-index:
62 stage: index
63 image: bluegit/python
64 timeout: 2h
65 resource_group: update-index
66 interruptible: false
67 needs: ["test:indexer", "test:plugin"]
68 rules:
69 - if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
70 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
71 when: manual
72 script:
73 - export PYTHONPATH="$PWD"
74 - pip install -q -r requirements-indexer.txt
75 - python3 indexer/build_index.py --dest public --incremental --max-pages 200
76 # Wiki-catalogus + next-links; --max-pages is het API-verzoekbudget.
77 - python3 -c "import json,pathlib; m=json.loads(pathlib.Path('public/catalog-meta.json').read_text()); print('index', m['novelCount'], 'verhalen', m['chapterCount'], 'hoofdstukken')"
78 - bash scripts/maybe-push-index.sh
79 artifacts:
80 paths:
81 - public/catalog-meta.json
82 - public/search-index.json
83 - public/catalog/
84 - public/series/
85 - public/covers/
86 - public/state.json
87 expire_in: 30d