|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + test-scraper: |
| 11 | + runs-on: ubuntu-24.04 |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version-file: scraper/pyproject.toml |
| 20 | + architecture: x64 |
| 21 | + |
| 22 | + - name: Install dependencies (and project) |
| 23 | + working-directory: scraper |
| 24 | + run: | |
| 25 | + pip install -U pip |
| 26 | + pip install -e .[test,scripts] |
| 27 | +
|
| 28 | + - name: Run the tests |
| 29 | + working-directory: scraper |
| 30 | + run: inv coverage --args "-vvv" |
| 31 | + |
| 32 | + - name: Upload coverage report to codecov |
| 33 | + uses: codecov/codecov-action@v4 |
| 34 | + with: |
| 35 | + fail_ci_if_error: true |
| 36 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 37 | + |
| 38 | + build-scraper: |
| 39 | + runs-on: ubuntu-24.04 |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Set up Python |
| 44 | + uses: actions/setup-python@v5 |
| 45 | + with: |
| 46 | + python-version-file: scraper/pyproject.toml |
| 47 | + architecture: x64 |
| 48 | + |
| 49 | + - name: Ensure we can build Python targets |
| 50 | + working-directory: scraper |
| 51 | + run: | |
| 52 | + pip install -U pip build |
| 53 | + python3 -m build --sdist --wheel |
| 54 | +
|
| 55 | + build-and-test-zimui: |
| 56 | + runs-on: ubuntu-24.04 |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Set up Node.js |
| 61 | + uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version-file: zimui/.node-version |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + working-directory: zimui |
| 67 | + run: | |
| 68 | + yarn install |
| 69 | +
|
| 70 | + - name: Test |
| 71 | + working-directory: zimui |
| 72 | + run: | |
| 73 | + yarn test:unit:run |
| 74 | +
|
| 75 | + - name: Build |
| 76 | + working-directory: zimui |
| 77 | + run: | |
| 78 | + yarn build |
| 79 | +
|
| 80 | + - name: Start web server |
| 81 | + working-directory: zimui |
| 82 | + run: | |
| 83 | + yarn preview & |
| 84 | +
|
| 85 | + - name: Wait for web server to be ready |
| 86 | + run: | |
| 87 | + npx wait-on http://localhost:4173 |
| 88 | +
|
| 89 | + - name: Run frontend tests |
| 90 | + working-directory: zimui |
| 91 | + run: | |
| 92 | + $(yarn bin)/cypress run |
| 93 | +
|
| 94 | + # this job replaces the standard "build_docker" job since it builds the docker image |
| 95 | + run-integration-tests: |
| 96 | + runs-on: ubuntu-24.04 |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v4 |
| 99 | + |
| 100 | + - name: Ensure we can build the Docker image |
| 101 | + run: | |
| 102 | + docker build -t libretexts2zim . |
| 103 | +
|
| 104 | + - name: Run scraper |
| 105 | + run: docker run -v $PWD/output:/output libretexts2zim libretexts2zim --library-slug geo --library-name Geosciences --file-name-format "tests_en_libretexts-geo" |
| 106 | + |
| 107 | + - name: Run integration test suite |
| 108 | + run: docker run -v $PWD/scraper/tests-integration:/src/scraper/tests-integration -v $PWD/output:/output libretexts2zim bash -c "pip install pytest; pytest -v /src/scraper/tests-integration" |
0 commit comments