-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (74 loc) · 3.08 KB
/
diff.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
name: Diff after_create method
on:
pull_request:
branches:
- main
paths:
- 'backend/model/**'
push:
jobs:
diff:
runs-on: ubuntu-latest
env:
PROD_ARCHIVESSPACE_VERSION: v3.3.1
continue-on-error: true
strategy:
matrix:
archivesspace_version: [v3.3.1, v3.4.1, v3.5.1]
steps:
- name: Checkout current plugin
uses: actions/checkout@v4
with:
path: plugin
sparse-checkout: |
backend/model
- name: Checkout ArchivesSpace baseline repo
uses: actions/checkout@v4
with:
ref: ${{ env.PROD_ARCHIVESSPACE_VERSION }}
repository: Smithsonian/archivesspace
path: archivesspace-baseline
sparse-checkout: |
backend/app/model
- name: Checkout ArchivesSpace repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.archivesspace_version }}
repository: Smithsonian/archivesspace
path: archivesspace
sparse-checkout: |
backend/app/model
- name: Create plugin file
run: |
touch plugin.txt
grep -wsh after_create ${{ github.workspace }}/plugin/backend/model/* -A 81 > plugin.txt
- name: Create prod version file
id: prod
run: |
touch prod.txt
grep -wsh after_create ${{ github.workspace }}/archivesspace-baseline/backend/app/model/repository.rb -A 81 > prod.txt
- name: Create ${{ matrix.archivesspace_version }} version file
run: |
touch ${{ matrix.archivesspace_version }}.txt
grep -wsh after_create ${{ github.workspace }}/archivesspace/backend/app/model/repository.rb -A 81 > ${{ matrix.archivesspace_version }}.txt
- name: Diff with baseline
id: baseline
run: |
echo "baseline_changes=$(git diff --diff-filter=M --shortstat ${{ github.workspace }}/prod.txt ${{ github.workspace }}/plugin.txt)" >> $GITHUB_OUTPUT
- name: Diff with new versions
id: new
run: |
echo "new_changes=$(git diff --diff-filter=M --shortstat ${{ github.workspace }}/${{ matrix.archivesspace_version }}.txt ${{ github.workspace }}/plugin.txt)" >> $GITHUB_OUTPUT
- name: Diffs match
if: ${{ steps.baseline.outputs.baseline_changes == steps.new.outputs.new_changes }}
run: |
echo "${{ steps.baseline.outputs.baseline_changes }}"
echo "${{ steps.new.outputs.new_changes }}"
echo "$(git diff --diff-filter=M -w --color -- ${{ github.workspace }}/${{ matrix.archivesspace_version }}.txt ${{ github.workspace }}/plugin.txt)"
echo "All models overridden by this plugin match $PROD_ARCHIVESSPACE_VERSION of ArchivesSpace"
- name: Diffs do not match
if: ${{ steps.baseline.outputs.baseline_changes != steps.new.outputs.new_changes }}
run: |
echo "Some models overridden by this plugin do not match those in ArchivesSpace ${{ matrix.archivesspace_version }}. See:"
echo "::set-output name=review_changes::$(git diff --diff-filter=M -w --color -- ${{ github.workspace }}/${{ matrix.archivesspace_version }}.txt ${{ github.workspace }}/plugin.txt)"
exit 1