Skip to content

Commit cacbb69

Browse files
authored
Refactor GHA (#189)
## what * Refactoring of the action * Added tests * Added `process-all` flag * Fix the action failure in case all affected stacks have not changed (artifact does not exist) * Fix the bug when an issue has wrong metadata or no metadata at all * Fix the bug when the summary size runs out of 1Mb limit ## why * Improve code readability * Gain insurance in the action stability * Fix the bug when the action runs in the `apply` workflow to close issues created by the `drift detection` workflow. * Fix apply and drift detection workflow when there is no stack with drift or error * Avoid failing of `apply` and `drift detection` workflows because of wrong metadata in one issue * Avoid errors because a summary is too big ## references * https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#step-isolation-and-limits * https://cloudposse.atlassian.net/browse/DEV-1562 * https://cloudposse.atlassian.net/browse/DEV-1561 * https://cloudposse.atlassian.net/browse/DEV-1560 * https://cloudposse.atlassian.net/browse/DEV-1555 * https://cloudposse.atlassian.net/browse/DEV-1559 * https://cloudposse.atlassian.net/browse/DEV-1135
1 parent 6f8486b commit cacbb69

19 files changed

+801
-388
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: "Test - Max opened issues"
2+
3+
on:
4+
# pull_request: {}
5+
workflow_dispatch: {}
6+
7+
env:
8+
AWS_REGION: us-east-2
9+
10+
# Permissions required for assuming AWS identity
11+
permissions:
12+
id-token: write
13+
contents: read
14+
issues: write
15+
16+
jobs:
17+
setup:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Setup
21+
run: echo "Do setup"
22+
23+
- uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.event.pull_request.head.ref }}
26+
27+
- name: Upload Artifacts
28+
uses: actions/upload-artifact@v3
29+
with:
30+
name: metadata
31+
path: ./tests/fixtures/metadata
32+
retention-days: 1
33+
34+
test:
35+
runs-on: ubuntu-latest
36+
continue-on-error: true
37+
needs: [setup]
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
ref: ${{ github.event.pull_request.head.ref }}
42+
43+
- name: Plan Atmos Component
44+
id: current
45+
uses: ./
46+
with:
47+
max-opened-issues: '3'
48+
labels: "test-max-opened-issues"
49+
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
50+
51+
outputs:
52+
result: ${{ steps.current.outcome }}
53+
54+
assert:
55+
runs-on: ubuntu-latest
56+
needs: [test]
57+
steps:
58+
- uses: nick-fields/assert-action@v1
59+
with:
60+
expected: 'success'
61+
actual: "${{ needs.test.outputs.result }}"
62+
63+
- name: Find all issues
64+
id: issues
65+
uses: lee-dohm/select-matching-issues@v1
66+
with:
67+
query: 'label:test-max-opened-issues is:open'
68+
token: ${{ github.token }}
69+
70+
- name: Close found issues
71+
id: test
72+
run: |
73+
cat ${{ steps.issues.outputs.path }}
74+
echo "count=$(cat ${{ steps.issues.outputs.path }} | xargs -I {} -d '\n' echo "{}" | wc -l )" >> $GITHUB_OUTPUT
75+
76+
- uses: nick-fields/assert-action@v1
77+
with:
78+
expected: '3'
79+
actual: "${{ steps.test.outputs.count }}"
80+
81+
teardown:
82+
runs-on: ubuntu-latest
83+
needs: [assert]
84+
if: ${{ always() }}
85+
steps:
86+
- name: Tear down
87+
run: echo "Do Tear down"
88+
89+
- name: Find all issues
90+
id: issues
91+
uses: lee-dohm/select-matching-issues@v1
92+
with:
93+
query: 'label:test-max-opened-issues is:open'
94+
token: ${{ github.token }}
95+
96+
- name: Close found issues
97+
run: cat ${{ steps.issues.outputs.path }} | xargs -I {} -d '\n' gh issue close {}
98+
env:
99+
GH_TOKEN: ${{ github.token }}

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ inputs:
2121
description: "Comma-separated list of additional labels to assign issues to."
2222
required: false
2323
default: ""
24+
process-all:
25+
description: "Process all issues or only the ones that relates to affected stacks. Default: false"
26+
required: false
27+
default: "false"
2428
token:
2529
description:
2630
Used to pull node distributions for Atmos from Cloud Posse's GitHub repository. Since there's a default, this is typically

0 commit comments

Comments
 (0)