-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (113 loc) · 3.7 KB
/
test.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
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
name: Test Updates
on:
pull_request:
paths:
- '.github/workflows/test.yml'
- 'src/**'
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI
permissions:
contents: read # Needed to read the repo
actions: read
issues: write # Needed to write comments
pull-requests: write
id-token: write
jobs:
test-project:
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker images
run: docker-compose -f docker-compose.yaml build base-image && docker-compose -f docker-compose.yaml build test-action
- name: Test
run: docker-compose -f docker-compose.yaml run test-action
generate-main-contract:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'main'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
version: 1.5.1
- name: Generate current contract
run: |
python -m venv .venv --upgrade-deps
source .venv/bin/activate
poetry install --no-interaction --no-ansi
aligned compile
- name: Archive new aligned contract
uses: actions/upload-artifact@v3
with:
name: contract-latest
path: contract_store.json
retention-days: 1
generate-new-contract:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
version: 1.5.1
- name: Generate current contract
run: |
python -m venv .venv --upgrade-deps
source .venv/bin/activate
poetry install --no-interaction --no-ansi
aligned compile
- name: Archive new aligned contract
uses: actions/upload-artifact@v3
with:
name: aligned-contract-${{ env.GITHUB_SHA }}
path: contract_store.json
retention-days: 1
check-for-contract-issues:
needs: [generate-new-contract, generate-main-contract]
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Install Aligned
run: pip install git+https://github.com/MatsMoll/aligned.git@matsei/load-dataset-as-job
- name: Download current schema
uses: actions/download-artifact@v3
with:
name: contract-latest
path: current-contract
- name: Download new schema
uses: actions/download-artifact@v3
with:
name: aligned-contract-${{ env.GITHUB_SHA }}
path: new-contract
- name: Generate Potentiall Issue Change Report
id: contract-update-report
run: |
aligned check-updates --updated-contract new-contract/contract_store.json --reference-contract current-contract/contract_store.json > report.md
echo $(cat report.md)
- name: Notify about potentiall issues
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const path = 'report.md'; // Update this path to your file
const body = fs.readFileSync(path, 'utf8').trim();
if (!body) {
console.log('File is empty, no comment created.');
return;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})