-
Notifications
You must be signed in to change notification settings - Fork 164
139 lines (132 loc) · 5.15 KB
/
eden.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
138
139
---
name: lf-edge/eden Test suite
# yamllint disable-line rule:truthy
on:
push:
branches:
- "master"
- "[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+-stable"
paths-ignore:
- '**/*.md'
- '.github/**'
pull_request_review:
types: [submitted]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check_md_wf_files:
if: ${{ github.event.review.state == 'approved' }}
runs-on: ubuntu-latest
outputs:
only_md: ${{ steps.check_md_wf.outputs.only_md }}
workflow_files_modified: ${{ steps.check_md_wf.outputs.workflow_files_modified }}
steps:
- name: Check if only Markdown files are changed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the list of modified files
PR_API_URL="${{ github.event.pull_request._links.self.href }}/files"
RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" $PR_API_URL)
# Check if the response is valid JSON
echo "$RESPONSE" | jq . > /dev/null || exit 1
MODIFIED_FILES=$(echo "$RESPONSE" | jq -r '.[].filename')
NON_MD_FILES=$(echo "$MODIFIED_FILES" | grep -v '\.md$' || true)
if [ -z "$NON_MD_FILES" ]; then
echo "All files are Markdown (.md) files."
echo "only_md=true" >> $GITHUB_ENV
else
echo "Non-Markdown files detected."
echo "only_md=false" >> $GITHUB_ENV
fi
# Check if any GitHub workflow files in .github/workflows are modified
if echo "$MODIFIED_FILES" | grep -qE '^\.github/workflows/.*\.(yml|yaml)$'; then
echo "GitHub workflow files in .github/workflows are modified."
echo "workflow_files_modified=true" >> $GITHUB_ENV
else
echo "No GitHub workflow files in .github/workflows are modified."
echo "workflow_files_modified=false" >> $GITHUB_ENV
fi
- name: Output result
id: check_md_wf
run: |
echo "${{ env.only_md }}"
echo "only_md=${{ env.only_md }}" >> $GITHUB_OUTPUT
echo "${{ env.workflow_files_modified }}"
echo "workflow_files_modified=${{ env.workflow_files_modified }}" >> $GITHUB_OUTPUT
get_run_id:
if: ${{ github.event.review.state == 'approved' && needs.check_md_wf_files.outputs.only_md == 'false' && needs.check_md_wf_files.outputs.workflow_files_modified == 'false' }}
runs-on: ubuntu-latest
needs: check_md_wf_files
outputs:
run_id: ${{ steps.get_run_id.outputs.run_id }}
steps:
- name: Get the GitHub context
run: echo "github context is $GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Print the head SHA
run: |
echo ${{ github.event.pull_request.head.sha }}
- name: Print pull request url
run: |
echo ${{ github.event.pull_request._links.self.href }}
- name: Get run ID for the artifact upload
id: get_run_id
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RESPONSE=$(curl -s -L "https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/runs?head_sha=${{ github.event.pull_request.head.sha }}&status=success" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json")
# Check if RESPONSE is empty
if [ -z "$RESPONSE" ]; then
echo "API call returned no response."
exit 1
fi
RUN_ID=$(echo $RESPONSE | jq -r '.workflow_runs[0].id')
# Check if the RUN_ID is empty
if [ "$RUN_ID" == "null" ] || [ -z "$RUN_ID" ]; then
echo "No successful runs found"
exit 1
fi
echo $RUN_ID
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
- name: Report Run ID # useful for debugging
run: echo "Run ID is ${{ steps.get_run_id.outputs.run_id }}"
test_suite_pr:
needs: get_run_id
strategy:
fail-fast: false
# we do not really need a matrix, as we only do amd64/kvm,
# but this makes it more consistent with the build, and will
# let us expand in the future, if we want
matrix:
arch: [amd64]
hv: [kvm]
platform: ["generic"]
if: github.event.review.state == 'approved'
uses: lf-edge/eden/.github/workflows/test.yml@1.0.1
secrets: inherit
with:
eve_image: "evebuild/pr:${{ github.event.pull_request.number }}"
eve_log_level: "debug"
eve_artifact_name: eve-${{ matrix.hv }}-${{ matrix.arch }}-${{ matrix.platform }}
artifact_run_id: ${{ needs.get_run_id.outputs.run_id }}
eden_version: "1.0.1"
test_suite_master:
if: github.ref == 'refs/heads/master'
uses: lf-edge/eden/.github/workflows/test.yml@1.0.1
secrets: inherit
with:
eve_image: "lfedge/eve:snapshot"
eden_version: "1.0.1"
test_suite_tag:
if: startsWith(github.ref, 'refs/tags')
uses: lf-edge/eden/.github/workflows/test.yml@1.0.1
secrets: inherit
with:
eve_image: "lfedge/eve:${{ github.ref_name }}"
eden_version: "1.0.1"