-
Notifications
You must be signed in to change notification settings - Fork 25
153 lines (135 loc) · 5.34 KB
/
optional-test.yaml
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: optional-test
on:
# Note about push & pull_request
# when creating a new branch for a PR, push will be triggered immediately before the PR gets created
# The GitHub API / GitHub context base commit is then 0000000000000000000000000000000000000000
#
# The get-changed-files action used in the detect_jobs_to_run needs to have a non 0 base commit to ba able to diff
# Defining both push (and specify the branches) and pull_request solves the problem
push:
branches:
# Push events our default branch
- dev
# Push events on our special branches
- patch-dev
- latest
- integration
pull_request:
paths-ignore:
- '*.md'
- 'renovate.json'
env:
PRISMA_TELEMETRY_INFORMATION: 'ecosystem-tests optional-test.yaml'
# To hide "Update available x.y.z -> x.y.z"
PRISMA_HIDE_UPDATE_MESSAGE: true
SLACK_WEBHOOK_URL_WORKFLOWS: ${{ secrets.SLACK_WEBHOOK_URL_OPTIONAL_WORKFLOWS }}
CI: 1
# TODO: Consolidate these env vars. They shouldn't be required for slack notification
# They are only required because `test-project.sh` hardcodes the names
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_OPTIONAL_TESTS_SUCCESS }}
SLACK_WEBHOOK_URL_FAILING: ${{ secrets.SLACK_WEBHOOK_URL_OPTIONAL_TESTS_FAILING }}
##
SLACK_WEBHOOK_URL_OPTIONAL_TESTS_SUCCESS: ${{ secrets.SLACK_WEBHOOK_URL_OPTIONAL_TESTS_SUCCESS }}
SLACK_WEBHOOK_URL_OPTIONAL_TESTS_FAILING: ${{ secrets.SLACK_WEBHOOK_URL_OPTIONAL_TESTS_FAILING }}
# To override the endpoint used by fetch-engine to download engines artifacts:
PRISMA_ENGINES_MIRROR: '' # 'https://pub-4c8d0335265c4484a8734643b596ecb2.r2.dev'
# These logs will make it easy to verify that `PRISMA_ENGINES_MIRROR` is used
# DEBUG: 'prisma:fetch-engine*'
defaults:
run:
# this makes windows use bash as well, which makes `... >> $GITHUB_ENV` work there
shell: bash
jobs:
# Depending on the output we will run some or all tests as fallback
detect_jobs_to_run:
name: Detect jobs to run
runs-on: ubuntu-22.04
outputs:
jobs: ${{ steps.detect.outputs.jobs }}
steps:
- id: checkout
uses: actions/checkout@v4
- id: files
uses: Ana06/[email protected] # it's a fork of jitterbit/get-changed-files@v1 which works better with pull requests
with:
format: 'json'
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- id: detect
run: ./.github/workflows/scripts/detect-jobs-to-run.js <<<'${{ steps.files.outputs.all }}'
report-to-slack-success:
runs-on: ubuntu-22.04
needs:
- community-generators
if: success() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/integration' || github.ref == 'refs/heads/patch-dev' || github.ref == 'refs/heads/latest')
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v4
with:
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: report success to slack
run: bash .github/scripts/slack-workflow-status.sh "(Optional tests) :white_check_mark:"
report-to-slack-failure:
runs-on: ubuntu-22.04
needs:
- community-generators
if: failure() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/integration' || github.ref == 'refs/heads/patch-dev' || github.ref == 'refs/heads/latest')
steps:
- uses: actions/checkout@v4
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v4
with:
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: report failure to slack
run: bash .github/scripts/slack-workflow-status.sh "(Optional tests) :x:"
community-generators:
needs: [detect_jobs_to_run]
if: contains(fromJSON(needs.detect_jobs_to_run.outputs.jobs), 'community-generators')
strategy:
fail-fast: false
matrix:
generator: [prisma-dbml-generator, typegraphql-prisma, prisma-json-schema-generator, prisma-nestjs-graphql]
clientEngine: ['library', 'binary']
runs-on: ubuntu-22.04
env:
DB_URL_COMMUNITY_GENERATOR_TYPEGRAPHQL_PRISMA: ${{ secrets.DB_URL_COMMUNITY_GENERATOR_TYPEGRAPHQL_PRISMA }}
steps:
- uses: actions/checkout@v4
- name: Define Client Engine Type to test
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV
- uses: pnpm/[email protected]
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
cache-dependency-path: ${{ github.job }}/${{ matrix.generator }}/pnpm-lock.yaml
- name: Install Dependencies
run: pnpm install
- name: test ${{ matrix.generator }} - ${{matrix.clientEngine}}
id: run-test
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: bash .github/scripts/test-project.sh ${{ github.job }} ${{ matrix.generator }}
- name: notify-slack
if: failure()
run: bash .github/slack/notify-failure.sh ${{ github.job }} ${{ matrix.generator }}