File size: 3,961 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
name: Automatisch UI Tests
on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - 'packages/backend/**'
      - 'packages/e2e-tests/**'
      - 'packages/web/**'
      - '!packages/backend/src/apps/**'
  workflow_dispatch:

env:
  ENCRYPTION_KEY: sample_encryption_key
  WEBHOOK_SECRET_KEY: sample_webhook_secret_key
  APP_SECRET_KEY: sample_app_secret_key
  POSTGRES_HOST: localhost
  POSTGRES_DATABASE: automatisch
  POSTGRES_PORT: 5432
  POSTGRES_USERNAME: automatisch_user
  POSTGRES_PASSWORD: automatisch_password
  REDIS_HOST: localhost
  APP_ENV: production
  LICENSE_KEY: dummy_license_key

jobs:
  test:
    timeout-minutes: 60
    runs-on:
      - ubuntu-latest
    services:
      postgres:
        image: postgres:14.5-alpine
        env:
          POSTGRES_DB: automatisch
          POSTGRES_USER: automatisch_user
          POSTGRES_PASSWORD: automatisch_password
        options: >-
          --health-cmd "pg_isready -U automatisch_user -d automatisch"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432
      redis:
        image: redis:7.0.4-alpine
        options: >-
          --health-cmd "redis-cli ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 6379:6379

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 18
      - name: Install dependencies
        run: yarn && yarn lerna bootstrap
      - name: Install Playwright Browsers
        run: yarn playwright install --with-deps
      - name: Build Automatisch web
        working-directory: ./packages/web
        run: yarn build
        env:
          # Keep this until we clean up warnings in build processes
          CI: false
      - name: Migrate database
        working-directory: ./packages/backend
        run: yarn db:migrate
      - name: Seed user
        working-directory: ./packages/backend
        run: yarn db:seed:user &
      - name: Install certutils
        run: sudo apt install -y libnss3-tools
      - name: Install mkcert
        run: |
          curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" \
          && chmod +x mkcert-v*-linux-amd64 \
          && sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
      - name: Install root certificate via mkcert
        run: mkcert -install
      - name: Create certificate
        run: mkcert automatisch.io "*.automatisch.io" localhost 127.0.0.1 ::1
        working-directory: ./packages/e2e-tests
      - name: Set CAROOT environment variable
        run: echo "NODE_EXTRA_CA_CERTS=$(mkcert -CAROOT)/rootCA.pem" >> "$GITHUB_ENV"
      - name: Override license server with local server
        run: sudo echo "127.0.0.1 license.automatisch.io" | sudo tee -a /etc/hosts
      - name: Run local license server
        working-directory: ./packages/e2e-tests
        run: sudo yarn start-mock-license-server &
      - name: Run Automatisch
        run: yarn start &
        working-directory: ./packages/backend
      - name: Run Automatisch worker
        run: yarn start:worker &
        working-directory: ./packages/backend
      - name: Setup upterm session
        if: false
        uses: lhotari/action-upterm@v1
        with:
          limit-access-to-actor: true
          limit-access-to-users: barinali
      - name: Run Playwright tests
        working-directory: ./packages/e2e-tests
        env:
          LOGIN_EMAIL: [email protected]
          LOGIN_PASSWORD: sample
          BASE_URL: http://localhost:3000
          GITHUB_CLIENT_ID: 1c0417daf898adfbd99a
          GITHUB_CLIENT_SECRET: 3328fa814dd582ccd03dbe785cfd683fb8da92b3
        run: yarn test
      - uses: actions/upload-artifact@v3
        if: always()
        with:
          name: playwright-report
          path: packages/e2e-tests/test-results
          retention-days: 30