summaryrefslogtreecommitdiffstats
path: root/.gitlab-ci.yml
blob: 6daf4679468e9dadbc40f7a6927541aff0f31ca9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
include:
  - local: '.gitlab/ci/prebuild.yml'
  - remote: https://gitlab.com/ynezz/openwrt-ci/raw/master/openwrt-ci/gitlab/main.yml

stages:
  - pre-build
  - test
  - deploy

check HTML, JS, CSS with eslint and prettier:
  stage: pre-build
  image: node
  cache:
    paths:
      - node_modules/
  script:
    - yarn install
    - yarn prettier --check www/
    - yarn eslint www/

check HTML, CSS and SVG with html5validator:
  stage: pre-build
  image: cyb3rjak3/html5validator:latest
  script:
    - html5validator --root www --also-check-css --show-warnings --log INFO

.build python:
  stage: pre-build
  image: python:$CI_PYTHON_VERSION-slim-buster
  before_script:
    - apt-get update; apt-get install -y make
  script:
    - cp -R ./www ./build
    - misc/collect.py scrape https://downloads.openwrt.org build
  artifacts:
    expire_in: 1 week
    when: always
    paths:
      - build

build site on Python 3.6:
  extends: .build python
  variables:
    CI_PYTHON_VERSION: "3.6"

build site on Python 3.8:
  extends: .build python
  variables:
    CI_PYTHON_VERSION: "3.8"

.build site:
  stage: pre-build
  image: debian:9
  before_script:
    - apt-get update; apt-get install -y make python3 ca-certificates git
  artifacts:
    expire_in: 1 week
    when: always
    paths:
      - build

build site for target environment using scrape method:
  extends: .build site
  script:
    - cp -R ./www ./build
    - sed -i "s;%GIT_VERSION%;$(git describe --tags);" build/index.html
    - misc/collect.py scrape https://downloads.openwrt.org build

build site for target environment using scan method:
  extends: .build site
  script:
    - cp -R ./www ./build
    - sed -i "s;%GIT_VERSION%;$(git describe --tags);" build/index.html
    - misc/collect.py scan downloads.openwrt.org tests/profiles build

.test site:
  stage: test
  image: selenium/standalone-firefox:latest
  script:
    - /opt/bin/entry_point.sh &
    - sudo apt-get update; sudo apt-get install -y python3-pip python3-pytest
    - pip3 install selenium-firefox
    - (cd build; python3 -m http.server &)
    - pytest-3 tests

test scraped site with selenium:
  extends: .test site
  dependencies:
    - build site for target environment using scrape method

test scaned site with selenium:
  extends: .test site
  dependencies:
    - build site for target environment using scan method

.deploy:
  stage: deploy
  image: alpine
  dependencies:
    - build site for target environment using scrape method
  before_script:
    - apk update && apk add rsync
  only:
    - master
    - tags
  script:
    - rsync -rlptvz build/ "rsync://firmware_selector@mirror-02.infra.openwrt.org/$RSYNC_TARGET/www/"

deploy to firmware-selector.staging.openwrt.org:
  extends: .deploy
  variables:
    RSYNC_TARGET: firmware-selector-staging-upload

deploy to firmware-selector.openwrt.org:
  extends: .deploy
  variables:
    RSYNC_TARGET: firmware-selector-upload
  when: manual
  only:
    - tags