|
1 | | -name: Build and Test app |
| 1 | +name: Build frontend, backend and Docker image |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - "**" |
7 | | - - "!hml" |
8 | | - - "!prd" |
9 | | - - "!prd-host" |
10 | 7 |
|
11 | 8 | jobs: |
12 | | - # Run tests. |
13 | | - # See also https://docs.docker.com/docker-hub/builds/automated-testing/ |
14 | 9 | build-frontend: |
15 | 10 | runs-on: ubuntu-latest |
16 | | - strategy: |
17 | | - matrix: |
18 | | - node-version: [12.x] |
| 11 | + workdir: frontend |
19 | 12 | steps: |
20 | | - - uses: actions/checkout@v2 |
21 | | - - name: Use Node.js ${{ matrix.node-version }} |
22 | | - uses: actions/setup-node@v1 |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v4 |
| 15 | + - uses: pnpm/action-setup@v4 |
| 16 | + working-directory: ./frontend |
| 17 | + name: Install pnpm |
23 | 18 | with: |
24 | | - node-version: ${{ matrix.node-version }} |
25 | | - - run: cd frontend && npm ci |
26 | | - - run: cd frontend && npm run check --if-present |
27 | | - - run: cd frontend && npm run test:static --if-present |
28 | | - - run: cd frontend && npm test --if-present |
29 | | - - run: cd frontend && npm run build --if-present |
| 19 | + version: 8 |
| 20 | + run_install: false |
| 21 | + - name: Install Node.js |
| 22 | + uses: actions/setup-node@v4 |
| 23 | + working-directory: ./frontend |
| 24 | + with: |
| 25 | + node-version: 20 |
| 26 | + cache: "pnpm" |
| 27 | + - name: Get pnpm store directory |
| 28 | + working-directory: ./frontend |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 32 | + - uses: actions/cache@v4 |
| 33 | + name: Setup pnpm cache |
| 34 | + working-directory: ./frontend |
| 35 | + with: |
| 36 | + path: ${{ env.STORE_PATH }} |
| 37 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-pnpm-store- |
| 40 | + - name: Install dependencies |
| 41 | + working-directory: ./frontend |
| 42 | + run: pnpm install |
| 43 | + - name: Build frontend |
| 44 | + working-directory: ./frontend |
| 45 | + run: pnpm build |
30 | 46 |
|
31 | | - build-django: |
| 47 | + build-backend: |
32 | 48 | runs-on: ubuntu-latest |
33 | 49 | needs: build-frontend |
34 | | - strategy: |
35 | | - max-parallel: 4 |
36 | | - matrix: |
37 | | - python-version: [3.8] |
38 | 50 | steps: |
39 | | - - uses: actions/checkout@v2 |
40 | | - - name: Set up Python ${{ matrix.python-version }} |
41 | | - uses: actions/setup-python@v1 |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v4 |
42 | 54 | with: |
43 | | - python-version: ${{ matrix.python-version }} |
44 | | - - name: Install Dependencies |
| 55 | + python-version: 3.12 |
| 56 | + - name: Install dependencies |
45 | 57 | run: | |
46 | 58 | python -m pip install --upgrade pip |
47 | | - pip install -r requirements.txt |
| 59 | + pip install poetry |
| 60 | + poetry install --no-dev |
48 | 61 | - name: Run Tests |
49 | 62 | env: |
50 | 63 | TEST: 1 |
51 | 64 | run: | |
52 | | - python manage.py test |
| 65 | + poetry run manage.py test |
53 | 66 |
|
54 | 67 | test-image: |
55 | 68 | runs-on: ubuntu-latest |
56 | 69 | needs: build-django |
57 | 70 | env: |
58 | 71 | SECRET_KEY: ${{ secrets.SECRET_KEY }} |
59 | 72 | steps: |
60 | | - - uses: actions/checkout@v2 |
61 | | - - name: Run tests |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + - name: Test Docker build |
62 | 75 | run: | |
63 | | - if [ -f docker-compose.test.yml ]; then |
64 | | - docker-compose --file docker-compose.test.yml build |
65 | | - docker-compose --file docker-compose.test.yml run sut |
66 | | - else |
67 | | - docker build . --build-arg AUTH_TOKEN=${{ secrets.AUTH_KEY }} --build-arg GTAG_ID=${{ secrets.GTAG_ID }} --file Dockerfile |
68 | | - fi |
| 76 | + docker build . --build-arg AUTH_TOKEN=${{ secrets.AUTH_KEY }} --file Dockerfile |
0 commit comments