-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (84 loc) · 3.07 KB
/
mySampleApp1-BATests.yml
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
name: MySampleApp1 - BA Tests
on:
repository_dispatch:
types: [mysampleapp1-ba-tests]
workflow_dispatch:
inputs:
environment:
description: "Select the environment"
required: true
type: environment
pr_number:
description: "Enter the PR number"
required: true
type: string
jobs:
behaviour-tests:
runs-on: arc-runner
steps:
- name: Determine environment
run: |
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
echo "SELECTED_ENV=${{ github.event.client_payload.environment }}" >> $GITHUB_ENV
else
echo "SELECTED_ENV=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
fi
- name: Determine pr number
run: |
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
echo "SELECTED_PR=${{ github.event.client_payload.pr_number }}" >> $GITHUB_ENV
else
echo "SELECTED_PR=${{ github.event.inputs.pr_number }}" >> $GITHUB_ENV
fi
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20.18.1'
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: npm ci
working-directory: ./apps/my-sample-app-1/mySampleApp1.behaviourTests
- name: Run tests
run: npm run test:${{ env.SELECTED_ENV }}
working-directory: ./apps/my-sample-app-1/mySampleApp1.behaviourTests
pr_status:
runs-on: ubuntu-latest
needs: [behaviour-tests]
steps:
- name: Determine environment
run: |
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
echo "SELECTED_ENV=${{ github.event.client_payload.environment }}" >> $GITHUB_ENV
else
echo "SELECTED_ENV=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
fi
- name: Determine pr number
run: |
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
echo "SELECTED_PR=${{ github.event.client_payload.pr_number }}" >> $GITHUB_ENV
else
echo "SELECTED_PR=${{ github.event.inputs.pr_number }}" >> $GITHUB_ENV
fi
- name: Set PR Status to Success
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = process.env.SELECTED_PR;
const { owner, repo } = context.repo;
// Fetch the latest commit SHA for the provided PR number
const { data: pullRequest } = await github.rest.pulls.get({
owner,
repo,
pull_number: prNumber
});
const sha = pullRequest.head.sha; // Get the SHA of the latest commit in the PR
await github.rest.repos.createCommitStatus({
owner: owner,
repo: repo,
sha: sha,
state: 'success',
context: 'BA Tests Check',
description: 'BA TESTS SUCCESSFUL',
});