Skip to content

Commit fe9e1ac

Browse files
committed
test workflow
1 parent 23ca4f8 commit fe9e1ac

File tree

4 files changed

+220
-70
lines changed

4 files changed

+220
-70
lines changed

.github/workflows/TestCalledWorkflow.yml

Lines changed: 61 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,78 @@ run-name: "TestCalledWorkflow"
33
on:
44
workflow_call:
55
inputs:
6-
test_type:
6+
actions_ref:
7+
description: 'JSON object reference to the actions: { "owner": "asterisk", "repo": "asterisk-ci-actions", "branch": "main" }'
78
type: string
8-
default: "Nightly"
9-
base_branch:
9+
required: false
10+
default: '{ "owner": "asterisk", "repo": "asterisk-ci-actions", "branch": "main" }'
11+
jobname:
1012
type: string
11-
default: master
12-
user_group:
13-
type: string
14-
default: asteriskci:users
15-
testsuite_repo:
16-
description: 'Testsuite Repo (default: asterisk/testsuite)'
17-
type: string
18-
default: asterisk/testsuite
19-
testsuite_test_pr:
20-
type: string
21-
gatetest_group:
22-
description: 'Gate Group'
23-
type: string
24-
default: "somegroup"
25-
gatetest_commands:
26-
description: 'Gate Commands'
27-
type: string
28-
default: '[]'
29-
build_cache_dir:
30-
type: string
31-
default: build-cache
32-
build_cache_key:
33-
type: string
34-
default: "akey"
13+
required: true
14+
secrets:
15+
TOKEN:
16+
required: true
3517

3618
env:
37-
WF_ENV: ${{ inputs.build_cache_dir }}
19+
ACTIONS_OWNER: asterisk
20+
ACTIONS_REPO: asterisk-ci-actions
21+
ACTIONS_BRANCH: main-test-native
22+
SCRIPT_DIR: ${{ github.workspace }}/asterisk-ci-actions/scripts
23+
GH_TOKEN: ${{secrets.TOKEN}}
24+
RUN_ID: ${{ github.run_id }}
3825

3926
jobs:
40-
41-
Setup:
42-
env:
43-
JOB_ENV: ${{ inputs.build_cache_key }}
27+
Job1:
28+
name: ${{inputs.jobname}}-Job1
4429
runs-on: ubuntu-latest
45-
container:
46-
image: ghcr.io/asterisk/asteriskci-agent-rocky8:latest
47-
options: --privileged
48-
4930
defaults:
5031
run:
5132
shell: bash
52-
5333
steps:
5434
- name: DumpEnvironment
5535
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
56-
- name: TestSysctl
36+
with:
37+
save_output: true
38+
artifact_id: DumpEnvironment-${{inputs.jobname}}-Job1
39+
40+
- name: test
5741
run: |
58-
sysctl -w kernel.core_pattern=/tmp/core-%e-%t
59-
sysctl -n kernel.core_pattern
60-
df -h
42+
mkdir logs
43+
step_summary=""
44+
step_summary+="FAILURE: rest_api/recording/duration\nFAILURE: rest_api/recording/nominal"
45+
echo -e "$step_summary" >> logs/STEP_SUMMARY
46+
exit 1
47+
- name: Save Output
48+
id: save-output
49+
if: ${{ always() }}
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: ${{inputs.jobname}}-Job1
53+
path: |
54+
logs
55+
56+
Job2:
57+
runs-on: ubuntu-latest
58+
name: ${{inputs.jobname}}-Job2
59+
defaults:
60+
run:
61+
shell: bash
62+
steps:
63+
- name: test
64+
run: |
65+
mkdir logs
66+
step_summary=""
67+
step_summary+="FAILURE: rest_api/recording/XXXXX\nFAILURE: rest_api/recording/YYYYYYY"
68+
echo -e "$step_summary" >> logs/STEP_SUMMARY
69+
exit 1
70+
- name: Save Output
71+
id: save-output
72+
if: ${{ always() }}
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: ${{inputs.jobname}}-Job2
76+
path: |
77+
logs
78+
- name: DumpEnvironment
79+
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
80+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: TestCallingWorkflow
2+
run-name: "TestCallingWorkflow"
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
ACTIONS_OWNER: asterisk
8+
ACTIONS_REPO: asterisk-ci-actions
9+
ACTIONS_BRANCH: main-test-native
10+
SCRIPT_DIR: ${{ github.workspace }}/asterisk-ci-actions/scripts
11+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
12+
RUN_ID: ${{ github.id }}
13+
14+
jobs:
15+
Setup:
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
shell: bash
20+
steps:
21+
- name: DumpEnvironment
22+
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
23+
with:
24+
save_output: true
25+
26+
TestCalled:
27+
needs: [ Setup ]
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
jobname: [ 'JobA', 'JobB' ]
32+
uses: ./.github/workflows/TestCalledWorkflow.yml
33+
with:
34+
jobname: ${{ matrix.jobname }}
35+
secrets:
36+
TOKEN: ${{secrets.GITHUB_TOKEN}}
37+
38+
Cleanup:
39+
needs: [ TestCalled ]
40+
runs-on: ubuntu-latest
41+
if: ${{ always() }}
42+
defaults:
43+
run:
44+
shell: bash
45+
steps:
46+
- name: test
47+
run: |
48+
gh --repo ${{ github.repository }} \
49+
run download ${RUN_ID} -D run-${RUN_ID}
50+
find run-${RUN_ID} -name STEP_SUMMARY
51+
for f in $(find run-${RUN_ID} -name STEP_SUMMARY) ; do
52+
cat $f >> $GITHUB_STEP_SUMMARY
53+
done
54+
cat $GITHUB_STEP_SUMMARY
55+
56+
- name: DumpEnvironment
57+
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
58+
with:
59+
save_output: true

.github/workflows/TestWorkflow.yml

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,78 @@ env:
88
ACTIONS_REPO: asterisk-ci-actions
99
ACTIONS_BRANCH: main-test-native
1010
SCRIPT_DIR: ${{ github.workspace }}/asterisk-ci-actions/scripts
11+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
12+
RUN_ID: ${{ github.id }}
1113

1214
jobs:
13-
Setup:
15+
Job1:
1416
runs-on: ubuntu-latest
1517
defaults:
1618
run:
1719
shell: bash
1820
steps:
19-
- name: Setup
21+
- name: DumpEnvironment
22+
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
23+
with:
24+
save_output: true
25+
26+
- name: test
2027
run: |
21-
# Setup
22-
pwd
23-
wget -qO asterisk-ci-actions.tar.gz \
24-
https://github.com/${ACTIONS_OWNER}/${ACTIONS_REPO}/archive/refs/heads/${ACTIONS_BRANCH}.tar.gz
25-
tar -xf asterisk-ci-actions.tar.gz --transform="s/^${ACTIONS_REPO}-${ACTIONS_BRANCH}/asterisk-ci-actions/g"
26-
# jq -r '. | from_entries' ${ACTIONS_REPO}/.github/control/asterisk-gh-test.json
27-
sed -i -r -e "s/^vars_/export vars_/g" ${ACTIONS_REPO}/.github/control/asterisk-gh-test.env
28-
source ${ACTIONS_REPO}/.github/control/asterisk-gh-test.env
29-
for VV in ${!vars_@} ; do
30-
echo "$VV=${!VV}" >> "${GITHUB_ENV}"
31-
done
28+
mkdir logs
29+
step_summary=""
30+
step_summary+="FAILURE: rest_api/recording/duration\nFAILURE: rest_api/recording/nominal"
31+
echo -e "$step_summary" >> logs/STEP_SUMMARY
32+
exit 1
33+
- name: Save Output
34+
id: save-output
35+
if: ${{ always() }}
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: job1
39+
path: |
40+
logs
3241
33-
- name: Printenv
42+
Job2:
43+
runs-on: ubuntu-latest
44+
defaults:
45+
run:
46+
shell: bash
47+
steps:
48+
- name: test
3449
run: |
35-
printenv
50+
mkdir logs
51+
step_summary=""
52+
step_summary+="FAILURE: rest_api/recording/XXXXX\nFAILURE: rest_api/recording/YYYYYYY"
53+
echo -e "$step_summary" >> logs/STEP_SUMMARY
54+
exit 1
55+
- name: Save Output
56+
id: save-output
57+
if: ${{ always() }}
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: job2
61+
path: |
62+
logs
63+
64+
Cleanup:
65+
needs: [Job1, Job2]
66+
runs-on: ubuntu-latest
67+
if: ${{ always() }}
68+
defaults:
69+
run:
70+
shell: bash
71+
steps:
72+
- name: test
73+
run: |
74+
gh --repo ${{ github.repository }} \
75+
run download ${RUN_ID} -D run-${RUN_ID}
76+
find run-${RUN_ID} -name STEP_SUMMARY
77+
for f in $(find run-${RUN_ID} -name STEP_SUMMARY) ; do
78+
cat $f >> $GITHUB_STEP_SUMMARY
79+
done
80+
cat $GITHUB_STEP_SUMMARY
3681
37-
# - name: DumpEnvironment
38-
# uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
82+
- name: DumpEnvironment
83+
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
84+
with:
85+
save_output: true

DumpEnvironmentAction/action.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,84 @@ inputs:
88
required: false
99
type: string
1010
default: '{}'
11+
save_output:
12+
type: boolean
13+
default: false
14+
artifact_id:
15+
type: string
16+
default: 'DumpEnvironment'
1117

1218
runs:
1319
using: "composite"
1420
steps:
1521
- name: "Dump github context"
1622
shell: bash
1723
run: |
24+
OUTPUT_DIR=/tmp/DumpEnvironment
25+
echo "SAVE_NAME=${SAVE_NAME}" >> ${GITHUB_ENV}
26+
echo "OUTPUT_DIR=${OUTPUT_DIR}" >> ${GITHUB_ENV}
27+
if [ -d ${OUTPUT_DIR} ] ; then
28+
rm -rf ${OUTPUT_DIR}
29+
fi
30+
mkdir ${OUTPUT_DIR}
1831
set +e +v +x
1932
echo "::group::inputs"
20-
cat <<%%EOF%%
33+
cat <<%%EOF%% | tee ${OUTPUT_DIR}/inputs.json
2134
${{toJSON(fromJSON(inputs.action-inputs))}}
2235
%%EOF%%
2336
echo "::endgroup::"
2437
2538
echo "::group::vars"
26-
cat <<%%EOF%%
39+
cat <<%%EOF%% | tee ${OUTPUT_DIR}/vars.json
2740
${{toJSON(fromJSON(inputs.action-vars))}}
2841
%%EOF%%
2942
echo "::endgroup::"
3043
3144
echo "::group::ctxenv"
32-
cat <<%%EOF%%
45+
cat <<%%EOF%% | tee ${OUTPUT_DIR}/job.env
3346
${{toJSON(env)}}
3447
%%EOF%%
3548
echo "::endgroup::"
3649
3750
echo "::group::env"
38-
printenv | sort
51+
printenv | sort | tee ${OUTPUT_DIR}/workflow.env
3952
echo "::endgroup::"
4053
4154
echo "::group::github_context"
42-
cat <<%%EOF%%
55+
cat <<%%EOF%% | tee ${OUTPUT_DIR}/context.json
4356
${{toJSON(github)}}
4457
%%EOF%%
4558
echo "::endgroup::"
4659
4760
echo "::group::GITHUB_WORKSPCE: ${GITHUB_WORKSPACE}"
48-
ls -al ${GITHUB_WORKSPACE}
61+
echo "${GITHUB_WORKSPACE}" > ${OUTPUT_DIR}/GITHUB_WORKSPACE.txt
62+
ls -al ${GITHUB_WORKSPACE} | tee -a ${OUTPUT_DIR}/GITHUB_WORKSPACE.txt
4963
echo "::endgroup::"
5064
5165
echo "::group::HOME: ${HOME}"
52-
ls -al ${HOME}
66+
echo "${HOME}" > ${OUTPUT_DIR}/HOME.txt
67+
ls -al ${HOME} | tee -a ${OUTPUT_DIR}/HOME.txt
5368
echo "::endgroup::"
5469
5570
echo "::group::RUNNER_WORKSPACE: ${RUNNER_WORKSPACE}"
56-
ls -al ${RUNNER_WORKSPACE}
71+
echo "${RUNNER_WORKSPACE}" > ${OUTPUT_DIR}/RUNNER_WORKSPACE.txt
72+
ls -al ${RUNNER_WORKSPACE} | tee -a ${OUTPUT_DIR}/RUNNER_WORKSPACE.txt
5773
echo "::endgroup::"
5874
5975
if [ -n "${GITHUB_ACTION_PATH}" ] ; then
6076
echo "::group::GITHUB_ACTION_PATH: ${GITHUB_ACTION_PATH}"
61-
ls -al ${GITHUB_ACTION_PATH}
77+
echo "${GITHUB_ACTION_PATH}" > ${OUTPUT_DIR}/GITHUB_ACTION_PATH.txt
78+
ls -al ${GITHUB_ACTION_PATH} | tee -a ${OUTPUT_DIR}/GITHUB_ACTION_PATH.txt
6279
echo "::endgroup::"
6380
fi
64-
65-
66-
6781
exit 0
82+
83+
- name: Save Output
84+
id: save-output
85+
if: ${{ inputs.save_output }}
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: ${{inputs.artifact_id}}
89+
path: |
90+
${{env.OUTPUT_DIR}}
91+

0 commit comments

Comments
 (0)