forked from orange-cloudfoundry/bosh-release-action
-
Notifications
You must be signed in to change notification settings - Fork 1
152 lines (150 loc) · 6.98 KB
/
on-commit.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
140
141
142
143
144
145
146
147
148
149
150
151
152
name: on-commit
on:
workflow_dispatch:
push:
jobs:
build:
name: "Test dev and final release creation"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout_repo
uses: actions/checkout@v4
with:
fetch-depth: 0
path: ./create-bosh-release-action
- name: Checkout repository test repo
id: checkout_test_repo
uses: actions/checkout@v4
with:
repository: 'orange-cloudfoundry/create-bosh-release-action-test-boshrelease'
fetch-depth: 0
# ref: v1.0
token: ${{ secrets.CREATE_BOSH_RELEASE_ACTION_TEST_BOSHRELEASE_GIT_TOKEN }}
path: ./create-bosh-release-action-test-boshrelease
- name: Setup test
run: |
git clone create-bosh-release-action-test-boshrelease dev-release-creation-test
git clone create-bosh-release-action-test-boshrelease final-release-creation-test
- name: Test dev release creation
id: test_dev_release
uses: ./create-bosh-release-action/ # uses: ./.github/actions/my-private-repo/my-action #https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-an-action-inside-a-different-private-repository-than-the-workflow
with:
target_branch: main
dir: dev-release-creation-test
- name: Generated test dev files status
run: |
ls -lrt
cd dev-release-creation-test
echo "Display dev-release-creation-test(create-bosh-release-action-test-boshrelease) git repo status:"
git status
echo "List existing tags:"
git tag --list
cd ..
- name: Test final release creation existing tag
id: test_final_release
uses: ./create-bosh-release-action/ # uses: ./.github/actions/my-private-repo/my-action #https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-an-action-inside-a-different-private-repository-than-the-workflow
with:
repository: orange-cloudfoundry/create-bosh-release-action-test-boshrelease
token: ${{ secrets.CREATE_BOSH_RELEASE_ACTION_TEST_BOSHRELEASE_GIT_TOKEN }}
target_branch: main
dir: final-release-creation-test
tag_name: "v0.3.0"
override_existing: "true"
debug: 1
- name: Assert final files status - override
env:
OUTPUT_VERSION: "${{ steps.test_final_release.outputs.version }}"
OUTPUT_TAGGED_VERSION: "${{ steps.test_final_release.outputs.tagged_version }}"
OUTPUT_NEED_GH_RELEASE: "${{ steps.test_final_release.outputs.need_gh_release }}"
EXPECTED_OUTPUT_VERSION: "0.3.0"
EXPECTED_OUTPUT_TAGGED_VERSION: "v0.3.0"
EXPECTED_OUTPUT_NEED_GH_RELEASE: "false"
run: |
ls -lrt
cd final-release-creation-test
echo "Display final-release-creation-test(create-bosh-release-action-test-boshrelease) git repo status:"
git status
echo "Checking tgz"
ls -l create-bosh-release-action-test-boshrelease-0.3.0.tgz
echo "List existing tags:"
git tag --list
echo "Ensure tag exist v0.3.0"
git tag --list|grep -E "^v0.3.0$"
cd ..
for o in OUTPUT_VERSION OUTPUT_TAGGED_VERSION OUTPUT_NEED_GH_RELEASE;do
output=$(echo "echo \$$o")
output_value=$(eval $output)
expected=$(echo "echo \$EXPECTED_$o")
expected_value=$(eval $expected)
if [[ "$expected_value" != "$output_value" ]];then
failure="true"
echo "ERROR: $o - expected_value ($expected_value) != output_value ($output_value)"
fi
done
if [ "$failure" = "true" ]; then
echo "Test failure detected"
exit 1
fi
- name: Get Next Version
id: semver-final-release
run: |
cd create-bosh-release-action-test-boshrelease
latest_tag=$(git describe --tags --abbrev=0)
echo "latest tag found: $latest_tag"
major_minor=$(echo $latest_tag|cut -d'.' -f1-2)
patch=$(echo $latest_tag|cut -d'.' -f3)
next_patch=$((patch + 1))
nextVersion=${major_minor}.$next_patch
nextStrictVersion=${major_minor#v}.$next_patch
echo "nextVersion: $nextVersion"
echo "nextVersion=$nextVersion" >> "$GITHUB_OUTPUT"
echo "nextStrictVersion=$nextStrictVersion" >> "$GITHUB_OUTPUT"
cd ..
- name: Test final release creation new tag
id: test_final_new_release
uses: ./create-bosh-release-action/ # uses: ./.github/actions/my-private-repo/my-action #https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-an-action-inside-a-different-private-repository-than-the-workflow
with:
repository: orange-cloudfoundry/create-bosh-release-action-test-boshrelease
token: ${{ secrets.CREATE_BOSH_RELEASE_ACTION_TEST_BOSHRELEASE_GIT_TOKEN }}
target_branch: main
dir: final-release-creation-test
tag_name: "${{ steps.semver-final-release.outputs.nextVersion }}"
override_existing: "false"
debug: 1
- name: Assert final files status - new
env:
NEXT_VERSION: "${{ steps.semver-final-release.outputs.nextVersion }}"
OUTPUT_VERSION: "${{ steps.test_final_new_release.outputs.version }}"
OUTPUT_TAGGED_VERSION: "${{ steps.test_final_new_release.outputs.tagged_version }}"
OUTPUT_NEED_GH_RELEASE: "${{ steps.test_final_new_release.outputs.need_gh_release }}"
EXPECTED_OUTPUT_VERSION: "${{ steps.semver-final-release.outputs.nextStrictVersion }}"
EXPECTED_OUTPUT_TAGGED_VERSION: "${{ steps.semver-final-release.outputs.nextVersion }}"
EXPECTED_OUTPUT_NEED_GH_RELEASE: "true"
run: |
ls -lrt
cd final-release-creation-test
echo "Display final-release-creation-test(create-bosh-release-action-test-boshrelease) git repo status:"
git status
echo "Checking tgz"
expected_version=${NEXT_VERSION#v}
ls -l create-bosh-release-action-test-boshrelease-$expected_version.tgz
echo "List existing tags:"
git tag --list
echo "Ensure tag exist"
git tag --list|grep -E "^$NEXT_VERSION$"
cd ..
for o in OUTPUT_VERSION OUTPUT_TAGGED_VERSION OUTPUT_NEED_GH_RELEASE;do
output=$(echo "echo \$$o")
output_value=$(eval $output)
expected=$(echo "echo \$EXPECTED_$o")
expected_value=$(eval $expected)
if [[ "$expected_value" != "$output_value" ]];then
failure="true"
echo "ERROR: $o - expected_value ($expected_value) != output_value ($output_value)"
fi
done
if [ "$failure" = "true" ]; then
echo "Test failure detected"
exit 1
fi