-
Notifications
You must be signed in to change notification settings - Fork 3
168 lines (139 loc) · 6.35 KB
/
e2e_conflicts.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: E2E Pulling Tests
on:
workflow_dispatch:
schedule:
- cron: '00 16 * * *'
jobs:
conflict-workflow:
concurrency: e2e-tests
permissions: write-all
runs-on: ubuntu-22.04
steps:
# Each job has to have this configuration because secrets can be passed through the output of
# another job
- name: Generate discourse configuration
id: configuration
run: |
echo "discourse= \
{ \
\"hostname\":\"discourse.charmhub.io\", \
\"category_id\":\"41\", \
\"api_username\":\"${{ secrets.DISCOURSE_API_USERNAME }}\", \
\"api_key\":\"${{ secrets.DISCOURSE_API_KEY }}\" \
}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Setup Python
run: |
sudo apt update && sudo apt install python3-pip git
pip3 install -r requirements.txt
- name: Prepare stage
id: prepare-stage
run: |
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action prepare --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
echo $(git log | head -n 1)
echo "Tags"
echo $(git tag -l | cat)
COMMIT_SHA=$(git log | head -n 1 | sed -En "s/commit\ //p")
echo "commit_sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
- name: Import Documentation
id: import
uses: canonical/upload-charm-docs@main
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
base_branch: "tests/base"
commit_sha: ${{ steps.prepare-stage.outputs.commit_sha }}
- name: Check creation
run: |
echo '${{ steps.import.outputs.pr_link }}'
echo '${{ steps.import.outputs.pr_action }}'
echo $(git log | head -n 1)
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action check-pull-request --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
echo $(git log | head -n 1)
echo "Tags"
echo $(git tag -l | cat)
- name: Merge PR
id: merge-import
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr merge ${{ steps.import.outputs.pr_link }} --squash
git pull
git branch -vv
git status
echo "Tags"
echo $(git tag -l | cat)
COMMIT_SHA=$(git log | head -n 1 | sed -En "s/commit\ //p")
echo "commit_sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
- name: Release Pipeline Documentation
id: release-import
uses: canonical/upload-charm-docs@main
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
base_branch: "tests/base"
commit_sha: ${{ steps.merge-import.outputs.commit_sha }}
- name: Create conflict
id: create-conflict
run: |
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action create-conflict --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
git status
COMMIT_SHA=$(git log | head -n 1 | sed -En "s/commit\ //p")
echo "commit_sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
- name: Raise Conflict in PR
id: conflict
continue-on-error: true
uses: canonical/upload-charm-docs@main
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
base_branch: "tests/base"
commit_sha: ${{ steps.create-conflict.outputs.commit_sha }}
- name: Resolve conflict
id: resolve-conflict
run: |
if [ ${{ steps.conflict.outcome }} != "failure" ]; then exit 1; fi
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action resolve-conflict --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
COMMIT_SHA=$(git log | head -n 1 | sed -En "s/commit\ //p")
echo "commit_sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
- name: Run Gatekeeper
id: feature-check
uses: canonical/upload-charm-docs@main
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
base_branch: "tests/base"
commit_sha: ${{ steps.resolve-conflict.outputs.commit_sha }}
- name: Merge Feature Branch
id: merge-feature
run: |
if [ ${{ steps.feature-check.outcome }} != "success" ]; then exit 1; fi
if [ ${{ steps.feature-check.outputs.pr_action }} != "opened" ]; then exit 1; fi
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action merge-feature --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'
COMMIT_SHA=$(git log | head -n 1 | sed -En "s/commit\ //p")
echo "commit_sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
- name: Release Feature
id: release-feature
uses: canonical/upload-charm-docs@main
with:
discourse_host: discourse.charmhub.io
discourse_api_username: ${{ secrets.DISCOURSE_API_USERNAME }}
discourse_api_key: ${{ secrets.DISCOURSE_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
base_branch: "tests/base"
commit_sha: ${{ steps.merge-feature.outputs.commit_sha }}
- name: Cleanup
run: |
if [ ${{ steps.release-feature.outputs.pr_action }} != "closed" ]; then exit 1; fi
PYTHONPATH=$(pwd) python3 tests/e2e/migrate.py --action cleanup --github-token ${{ secrets.GITHUB_TOKEN }} '${{ steps.configuration.outputs.discourse }}'