|
1 | 1 | name: Test |
2 | 2 |
|
3 | | -# **What it does**: Runs our tests. |
4 | | -# **Why we have it**: We want our tests to pass before merging code. |
5 | | -# **Who does it impact**: Docs engineering, open-source engineering contributors. |
6 | | -# |
7 | | -# For a catalog of what each suite covers and how risky it is to admin-merge |
8 | | -# past it when red, see src/tests/SUITES.md. |
9 | | - |
10 | 3 | on: |
11 | | - workflow_dispatch: |
12 | | - merge_group: |
| 4 | + push: |
| 5 | + branches: [ "main", "master" ] |
13 | 6 | pull_request: |
14 | | - |
15 | | -permissions: |
16 | | - contents: read |
17 | | - pull-requests: read |
18 | | - |
19 | | -# This allows a subsequently queued workflow run to interrupt previous runs |
20 | | -concurrency: |
21 | | - group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' |
22 | | - cancel-in-progress: true |
23 | | - |
24 | | -env: |
25 | | - # Setting this will activate the vitest tests that depend on actually |
26 | | - # sending real search queries to Elasticsearch |
27 | | - ELASTICSEARCH_URL: http://localhost:9200/ |
| 7 | + branches: [ "main", "master" ] |
| 8 | + workflow_dispatch: |
28 | 9 |
|
29 | 10 | jobs: |
30 | 11 | test: |
31 | | - name: ${{ matrix.name }} |
32 | | - if: github.repository == 'github/docs-internal' || github.repository == 'github/docs' |
| 12 | + name: Run Route Tests |
33 | 13 | runs-on: ubuntu-latest |
34 | | - timeout-minutes: 60 |
35 | | - strategy: |
36 | | - fail-fast: false |
37 | | - matrix: |
38 | | - # Note that *if you add* to this, remember to also add that |
39 | | - # to the **required checks** in the branch protection rules. |
40 | | - name: |
41 | | - # src/ directory |
42 | | - - archives |
43 | | - - article-api |
44 | | - - assets |
45 | | - - audit-logs |
46 | | - - automated-pipelines |
47 | | - # - bookmarklets |
48 | | - # - code-scanning |
49 | | - # - codeql-cli |
50 | | - - color-schemes |
51 | | - - content-linter |
52 | | - - content-render |
53 | | - - data-directory |
54 | | - # - dev-toc |
55 | | - - early-access |
56 | | - - events |
57 | | - - fixtures |
58 | | - - frame |
59 | | - - github-apps |
60 | | - - graphql |
61 | | - - landings |
62 | | - - languages |
63 | | - # - links |
64 | | - - observability |
65 | | - # - open-source |
66 | | - # - pages |
67 | | - - products |
68 | | - - redirects |
69 | | - - release-notes |
70 | | - - rest |
71 | | - - search |
72 | | - - secret-scanning |
73 | | - - shielding |
74 | | - # - tests |
75 | | - # - tools |
76 | | - - versions |
77 | | - - webhooks |
78 | | - - workflows |
79 | | - |
80 | | - # The languages suite only runs on docs-internal |
81 | | - isPrivateRepo: |
82 | | - - ${{ github.repository == 'github/docs-internal' }} |
83 | | - exclude: |
84 | | - - name: languages |
85 | | - isPrivateRepo: false |
86 | 14 |
|
87 | 15 | steps: |
88 | | - # Each of these ifs needs to be repeated at each step to make sure the required check still runs |
89 | | - # Even if if doesn't do anything |
90 | 16 | - name: Check out repo |
91 | | - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
92 | | - with: |
93 | | - # Fetch 2 commits so tj-actions/changed-files can diff without extra API calls |
94 | | - fetch-depth: 2 |
95 | | - |
96 | | - - uses: ./.github/actions/setup-elasticsearch |
97 | | - if: ${{ matrix.name == 'search' || matrix.name == 'languages' }} |
| 17 | + uses: actions/checkout@v4 |
98 | 18 |
|
99 | | - - uses: ./.github/actions/node-npm-setup |
100 | | - |
101 | | - - uses: ./.github/actions/get-docs-early-access |
102 | | - if: ${{ github.repository == 'github/docs-internal' }} |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
103 | 21 | with: |
104 | | - token: ${{ secrets.DOCS_BOT_PAT_BASE }} |
105 | | - |
106 | | - - name: Check the test fixture data (if applicable) |
107 | | - if: ${{ matrix.name == 'fixtures' }} |
108 | | - run: npm run copy-fixture-data -- --check |
| 22 | + python-version: "3.10" |
109 | 23 |
|
110 | | - # This keeps our fixture content/data in check |
111 | | - - name: Check the test fixture content (if applicable) |
112 | | - if: ${{ matrix.name == 'fixtures' }} |
113 | | - env: |
114 | | - ROOT: src/fixtures/fixtures |
| 24 | + - name: Install dependencies |
115 | 25 | run: | |
116 | | - # If either of these fail, it means our fixture content's internal |
117 | | - # links can and should be updated. |
118 | | - npm run update-internal-links -- --dry-run --check --strict \ |
119 | | - src/fixtures/fixtures/content \ |
120 | | - --exclude src/fixtures/fixtures/content/get-started/foo/typo-autotitling.md \ |
121 | | - --exclude src/fixtures/fixtures/content/get-started/foo/anchor-autotitling.md |
122 | | - npm run update-internal-links -- --dry-run --check --strict \ |
123 | | - src/fixtures/fixtures/data |
124 | | -
|
125 | | - - name: Clone all translations |
126 | | - if: ${{ matrix.name == 'languages' }} |
127 | | - uses: ./.github/actions/clone-translations |
128 | | - with: |
129 | | - token: ${{ secrets.DOCS_BOT_PAT_BASE }} |
130 | | - |
131 | | - - name: Gather files changed |
132 | | - if: ${{ matrix.name == 'content-linter' }} |
133 | | - id: changed_files |
134 | | - uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5 |
135 | | - |
136 | | - - name: Write changed files to diff file |
137 | | - if: ${{ matrix.name == 'content-linter' }} |
138 | | - run: echo "${{ steps.changed_files.outputs.all_modified_files }}" > get_diff_files.txt |
139 | | - |
140 | | - - uses: ./.github/actions/cache-nextjs |
141 | | - |
142 | | - - name: Run build script |
143 | | - run: npm run build |
144 | | - |
145 | | - - uses: ./.github/actions/warmup-remotejson-cache |
146 | | - # Only the 'routing' tests include end-to-end tests about |
147 | | - # archived enterprise server URLs. |
148 | | - if: ${{ matrix.name == 'redirects' }} |
149 | | - |
150 | | - - uses: ./.github/actions/precompute-pageinfo |
151 | | - # Only the 'pageinfo' tests include end-to-end tests about this. |
152 | | - if: ${{ matrix.name == 'article-api' }} |
153 | | - env: |
154 | | - ROOT: src/fixtures/fixtures |
155 | | - |
156 | | - - name: Index fixtures into the local Elasticsearch |
157 | | - # For the sake of saving time, only run this step if the group |
158 | | - # is one that will run tests against an Elasticsearch on localhost. |
159 | | - if: ${{ matrix.name == 'search' || matrix.name == 'languages' }} |
160 | | - run: npm run index-test-fixtures |
| 26 | + python -m pip install --upgrade pip |
| 27 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
161 | 28 |
|
162 | 29 | - name: Run tests |
163 | 30 | env: |
164 | | - DIFF_FILE: get_diff_files.txt |
165 | | - CHANGELOG_CACHE_FILE_PATH: src/fixtures/fixtures/changelog-feed.json |
166 | | - # By default, when `process.env.NODE_ENV === 'test'` it forces the |
167 | | - # tests run only in English. The exception is the |
168 | | - # `languages` suite which needs all languages to be set up. |
169 | | - ENABLED_LANGUAGES: ${{ matrix.name == 'languages' && 'all' || '' }} |
170 | | - ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'article-api' || matrix.name == 'landings' ) && 'src/fixtures/fixtures' || '' }} |
171 | | - TRANSLATIONS_FIXTURE_ROOT: ${{ (matrix.name == 'fixtures' || matrix.name == 'article-api') && 'src/fixtures/fixtures/translations' || '' }} |
172 | | - # Enable debug logging when "Re-run jobs with debug logging" is used in GitHub Actions UI |
173 | | - # This will output additional timing and path information to help diagnose timeout issues |
174 | | - RUNNER_DEBUG: ${{ runner.debug }} |
175 | | - VITEST_FLAGS: ${{ matrix.name == 'article-api' && '--no-file-parallelism --maxWorkers=1' || '' }} |
176 | | - run: npm test -- $VITEST_FLAGS src/${{ matrix.name }}/tests/ |
| 31 | + PYTHONUNBUFFERED: "1" |
| 32 | + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} |
| 33 | + run: python -u tests/test_routes.py |
0 commit comments