summaryrefslogtreecommitdiff
path: root/.circleci/config.yml
blob: f5bd44798965ce11bab0f8c0d54dfb51ac500980 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Python CircleCI 2.1 configuration file
#
# Check https://circleci.com/docs/2.1/language-python/ for more details
#
version: 2.1

# Aliases to reuse
_defaults: &defaults
  docker:
    # CircleCI maintains a library of pre-built images
    # documented at https://circleci.com/docs/2.1/circleci-images/
    # circleci/python3.8 images come with old versions of Doxygen(1.6.x),
    # therefore a new base image chose instead to guarantee to
    # have a newer version >= 1.8.10 to avoid warnings
    # that related to the default behaviors or non-exist config options
    - image: cimg/python:3.9
  working_directory: ~/repo


jobs:
  build:
    <<: *defaults
    steps:
      - checkout

      - run:
          name: Check-skip
          command: |
            export git_log=$(git log --max-count=1 --pretty=format:"%B" | tr "\n" " ")
            echo "Got commit message:"
            echo "${git_log}"
            if [[ -v CIRCLE_PULL_REQUEST ]] && \
               ([[ "$git_log" == *"[skip circle]"* ]] || \
                [[ "$git_log" == *"[circle skip]"* ]])
            then
              echo "Skip detected, exiting job ${CIRCLE_JOB} for PR ${CIRCLE_PULL_REQUEST}."
              circleci-agent step halt;
            fi
      - run:
          name: pull changes from merge
          command: |
            if [[ -v CI_PULL_REQUEST ]] ; then git pull --ff-only origin "refs/pull/${CI_PULL_REQUEST//*pull\//}/merge" ; fi

      - run:
          name: update submodules
          command: |
            git submodule init
            git submodule update

      - run:
          name: create virtual environment, install dependencies
          command: |
            sudo apt-get update
            #sudo apt-get install -y python3.9 python3.9-dev python3-venv graphviz texlive-fonts-recommended texlive-latex-recommended \
            sudo apt-get install -y graphviz texlive-fonts-recommended texlive-latex-recommended \
              texlive-latex-extra latexmk texlive-xetex texlive-lang-chinese doxygen
            python3.9 -m venv venv
            . venv/bin/activate

      - run:
          name: build numpy
          command: |
            . venv/bin/activate
            pip install --progress-bar=off --upgrade pip 'setuptools<49.2.0'
            pip install --progress-bar=off -r test_requirements.txt
            pip install --progress-bar=off -r doc_requirements.txt
            pip install .

      - run:
          name: create release notes
          command: |
            . venv/bin/activate
            VERSION=$(python -c "import setup; print(setup.VERSION)")
            towncrier build --version $VERSION --yes
            ./tools/ci/test_all_newsfragments_used.py

      - run:
          name: run doctests on documentation
          command: |
            . venv/bin/activate
            (cd doc ; git submodule update --init)
            python tools/refguide_check.py --rst

      - run:
          name: build devdocs w/ref warnings
          command: |
            . venv/bin/activate
            cd doc
            # Don't use -q, show warning summary"
            SPHINXOPTS="-j2 -n" make -e html || echo "ignoring errors for now, see gh-13114"
            if [[ $(find build/html -type f | wc -l) -lt 1000 ]]; then
                echo "doc build failed: build/html is empty"
                exit -1
            fi

      - run:
          name: build neps
          command: |
            . venv/bin/activate
            cd doc/neps
            SPHINXOPTS="-j2 -q" make -e html

      - store_artifacts:
          path: doc/build/html/

      - store_artifacts:
          path: doc/neps/_build/html/
     #      destination: neps

      - persist_to_workspace:
          root: ~/repo
          paths:
            - doc/build/html
            - doc/neps/_build
            - tools/ci/push_docs_to_repo.py

  deploy:
    <<: *defaults
    steps:
      - checkout

      - attach_workspace:
          at: ~/repo

      - add_ssh_keys:
          fingerprints:
            - "45:d8:d1:d6:f7:53:47:c5:d0:9e:35:19:79:e7:ff:24"

      -  run:
          name: deploy devdocs
          command: |
            touch doc/build/html/.nojekyll

            ./tools/ci/push_docs_to_repo.py doc/build/html \
                --committer "numpy-circleci-bot" \
                --email "numpy-circleci-bot@nomail" \
                --message "Docs build of $CIRCLE_SHA1" \
                --count 5 \
                --force \
                git@github.com:numpy/devdocs.git

      - add_ssh_keys:
          fingerprints:
            - "df:8b:fb:34:2d:38:7d:49:fc:1b:e8:44:4f:bd:2c:0e"

      - run:
          name: select SSH key for neps repo
          command: |
            cat \<<\EOF > ~/.ssh/config
            Host github.com
              IdentitiesOnly yes
              IdentityFile /home/circleci/.ssh/id_rsa_df8bfb342d387d49fc1be8444fbd2c0e
            EOF

      -  run:
          name: deploy neps
          command: |
            touch doc/neps/_build/html/.nojekyll

            ./tools/ci/push_docs_to_repo.py doc/neps/_build/html \
                --committer "numpy-circleci-bot" \
                --email "numpy-circleci-bot@nomail" \
                --message "Docs build of $CIRCLE_SHA1" \
                --count 5 \
                --force \
                git@github.com:numpy/neps.git \

workflows:
  version: 2
  default:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: main