|
| 1 | +name: CI |
| 2 | +on: [push, pull_request] |
| 3 | + |
| 4 | +jobs: |
| 5 | + test: |
| 6 | + strategy: |
| 7 | + matrix: |
| 8 | + include: |
| 9 | + - name: Tests |
| 10 | + command: bin/tests --postgresql-host localhost |
| 11 | + needs-python: ${{ true }} |
| 12 | + needs-node: ${{ false }} |
| 13 | + - name: Lint |
| 14 | + command: bin/scss-check |
| 15 | + needs-python: ${{ false }} |
| 16 | + needs-node: ${{ true }} |
| 17 | + runs-on: ubuntu-latest |
| 18 | + services: |
| 19 | + postgres: |
| 20 | + image: postgres:10.1 |
| 21 | + ports: |
| 22 | + - 5432:5432 |
| 23 | + options: >- |
| 24 | + --health-cmd pg_isready |
| 25 | + --health-interval 10s |
| 26 | + --health-timeout 5s |
| 27 | + --health-retries 5 |
| 28 | + name: ${{ matrix.name }} |
| 29 | + steps: |
| 30 | + - name: Check out repository |
| 31 | + uses: actions/checkout@v2 |
| 32 | + - name: Install platform dependencies |
| 33 | + run: | |
| 34 | + sudo apt -y update |
| 35 | + sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config |
| 36 | + - uses: actions/setup-python@v2 |
| 37 | + if: ${{ matrix.needs-python }} |
| 38 | + with: |
| 39 | + python-version: 3.6.6 |
| 40 | + - name: Cache Python dependencies |
| 41 | + if: ${{ matrix.needs-python }} |
| 42 | + uses: actions/cache@v2 |
| 43 | + env: |
| 44 | + cache-name: pythondotorg-cache-pip |
| 45 | + with: |
| 46 | + path: ~/.cache/pip |
| 47 | + key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('dev-requirements.txt') }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}- |
| 50 | + ${{ runner.os }}-${{ github.job }}- |
| 51 | + ${{ runner.os }}- |
| 52 | + - name: Install Python dependencies |
| 53 | + if: ${{ matrix.needs-python }} |
| 54 | + run: | |
| 55 | + pip install -U pip setuptools wheel |
| 56 | + pip install -r dev-requirements.txt |
| 57 | + - uses: actions/setup-node@v2 |
| 58 | + if: ${{ matrix.needs-node }} |
| 59 | + with: |
| 60 | + node-version: 14 |
| 61 | + - name: Cache Node dependencies |
| 62 | + if: ${{ matrix.needs-node }} |
| 63 | + uses: actions/cache@v2 |
| 64 | + env: |
| 65 | + cache-name: warehouse-cache-npm |
| 66 | + with: |
| 67 | + path: ~/.npm |
| 68 | + key: ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }} |
| 69 | + restore-keys: | |
| 70 | + ${{ runner.os }}-build-${{ github.job }}-${{ env.cache-name }}- |
| 71 | + ${{ runner.os }}-build-${{ github.job }}- |
| 72 | + ${{ runner.os }}-build- |
| 73 | + ${{ runner.os }}- |
| 74 | + - name: Create DB |
| 75 | + run: psql -c 'create database "python.org";' -U postgres |
| 76 | + - name: Install Node dependencies |
| 77 | + if: ${{ matrix.needs-node }} |
| 78 | + run: npm ci |
| 79 | + - name: Run ${{ matrix.name }} |
| 80 | + run: ${{ matrix.command }} |
| 81 | + env: |
| 82 | + DATABASE_URL: postgres://postgres:@127.0.0.1:5432/python.org |
0 commit comments