1111 description : ' Create Production Release'
1212 required : true
1313 type : boolean
14+ skiptests :
15+ description : ' Skip Tests'
16+ required : true
17+ type : boolean
18+ summary :
19+ description : ' Summary'
20+ required : false
21+ type : string
22+ default : ' '
1423
1524jobs :
16- publish :
25+ # -----------------------------------------------------------------
26+ # PREPARE
27+ # -----------------------------------------------------------------
28+ prepare :
29+ name : Prepare Release
1730 runs-on : ubuntu-latest
31+ outputs :
32+ should_deploy : ${{ steps.buildvars.outputs.should_deploy }}
33+ pkg_version : ${{ steps.buildvars.outputs.pkg_version }}
34+ pkg_version_strict : ${{ steps.buildvars.outputs.pkg_version_strict }}
1835
1936 steps :
2037 - uses : actions/checkout@v2
2138 with :
2239 fetch-depth : 0
23-
40+
2441 - name : Get Next Version
2542 if : ${{ github.event.inputs.publish == 'true' }}
2643 id : semver
@@ -49,26 +66,103 @@ jobs:
4966 token : ${{ secrets.GITHUB_TOKEN }}
5067
5168 - name : Set Build Variables
69+ id : buildvars
5270 run : |
5371 if [[ $NEXT_VERSION ]]; then
5472 echo "Using AUTO SEMVER mode: $NEXT_VERSION"
55- echo "SHOULD_DEPLOY= true" >> $GITHUB_ENV
56- echo "PKG_VERSION= $NEXT_VERSION" >> $GITHUB_ENV
57- echo "PKG_VERSION_STRICT= ${NEXT_VERSION#?}" >> $GITHUB_ENV
73+ echo "::set-output name=should_deploy:: true"
74+ echo "::set-output name=pkg_version:: $NEXT_VERSION"
75+ echo "::set-output name=pkg_version_strict:: ${NEXT_VERSION#?}"
5876 echo "::notice::Release created using branch $GITHUB_REF_NAME"
5977 elif [[ "$GITHUB_REF" =~ ^refs/tags/v* ]]; then
6078 echo "Using TAG mode: $GITHUB_REF_NAME"
61- echo "SHOULD_DEPLOY= true" >> $GITHUB_ENV
62- echo "PKG_VERSION= $GITHUB_REF_NAME" >> $GITHUB_ENV
63- echo "PKG_VERSION_STRICT= ${GITHUB_REF_NAME#?}" >> $GITHUB_ENV
79+ echo "::set-output name=should_deploy:: true"
80+ echo "::set-output name=pkg_version:: $GITHUB_REF_NAME"
81+ echo "::set-output name=pkg_version_strict:: ${GITHUB_REF_NAME#?}"
6482 echo "::notice::Release created using tag $GITHUB_REF_NAME"
6583 else
6684 echo "Using TEST mode: v7.0.0-dev.$GITHUB_RUN_NUMBER"
67- echo "SHOULD_DEPLOY= false" >> $GITHUB_ENV
68- echo "PKG_VERSION=v3 .0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
69- echo "PKG_VERSION_STRICT=3 .0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
85+ echo "::set-output name=should_deploy:: false"
86+ echo "::set-output name=pkg_version::v7 .0.0-dev.$GITHUB_RUN_NUMBER"
87+ echo "::set-output name=pkg_version_strict::7 .0.0-dev.$GITHUB_RUN_NUMBER"
7088 echo "::notice::Non-production build created using branch $GITHUB_REF_NAME"
7189 fi
90+
91+ # -----------------------------------------------------------------
92+ # TESTS
93+ # -----------------------------------------------------------------
94+ tests :
95+ name : Run Tests
96+ if : ${{ github.event.inputs.skiptests == 'false' }}
97+ needs : [prepare]
98+ runs-on : ubuntu-latest
99+ container : ghcr.io/ietf-tools/datatracker-test-base:latest
100+
101+ services :
102+ db :
103+ image : ghcr.io/ietf-tools/datatracker-db:latest
104+ volumes :
105+ - mariadb-data:/var/lib/mysql
106+ env :
107+ MYSQL_ROOT_PASSWORD : ietf
108+ MYSQL_DATABASE : ietf_utf8
109+ MYSQL_USER : django
110+ MYSQL_PASSWORD : RkTkDPFnKpko
111+
112+ steps :
113+ - uses : actions/checkout@v3
114+
115+ - name : Prepare for tests
116+ run : |
117+ chmod +x ./dev/tests/prepare.sh
118+ sh ./dev/tests/prepare.sh
119+
120+ - name : Ensure DB is ready
121+ run : |
122+ /usr/local/bin/wait-for db:3306 -- echo "DB ready"
123+
124+ - name : Run all tests
125+ run : |
126+ echo "Running checks..."
127+ ./ietf/manage.py check
128+ echo "Running tests..."
129+ ./ietf/manage.py test --settings=settings_sqlitetest
130+ coverage xml
131+
132+ - name : Upload Coverage Results to Codecov
133+ uses : codecov/codecov-action@v2.1.0
134+ with :
135+ files : coverage.xml
136+
137+ - name : Convert Coverage Results
138+ if : ${{ always() }}
139+ run : |
140+ mv latest-coverage.json coverage.json
141+
142+ - name : Upload Coverage Results as Build Artifact
143+ uses : actions/upload-artifact@v3.0.0
144+ if : ${{ always() }}
145+ with :
146+ name : coverage
147+ path : coverage.json
148+
149+ # -----------------------------------------------------------------
150+ # RELEASE
151+ # -----------------------------------------------------------------
152+ release :
153+ name : Make Release
154+ if : ${{ always() }}
155+ needs : [tests, prepare]
156+ runs-on : ubuntu-latest
157+ env :
158+ SHOULD_DEPLOY : ${{needs.prepare.outputs.should_deploy}}
159+ PKG_VERSION : ${{needs.prepare.outputs.pkg_version}}
160+ PKG_VERSION_STRICT : ${{needs.prepare.outputs.pkg_version_strict}}
161+
162+ steps :
163+ - uses : actions/checkout@v2
164+ with :
165+ fetch-depth : 0
72166
73167 - name : Setup Node.js
74168 uses : actions/setup-node@v3.0.0
@@ -80,17 +174,27 @@ jobs:
80174 with :
81175 python-version : ' 3.x'
82176
177+ - name : Download a Coverage Results
178+ if : ${{ github.event.inputs.skiptests == 'false' }}
179+ uses : actions/download-artifact@v3.0.0
180+ with :
181+ name : coverage
182+
83183 - name : Make Release Build
84184 env :
85185 DEBIAN_FRONTEND : noninteractive
86186 run : |
187+ echo "PKG_VERSION: $PKG_VERSION"
188+ echo "PKG_VERSION_STRICT: $PKG_VERSION_STRICT"
189+ echo "GITHUB_SHA: $GITHUB_SHA"
190+ echo "GITHUB_REF_NAME: $GITHUB_REF_NAME"
87191 echo "Running build script..."
88192 chmod +x ./dev/deploy/build.sh
89193 sh ./dev/deploy/build.sh
90194 echo "Setting version $PKG_VERSION_STRICT..."
91- sed -i -r -e "s/ ^__version__ += '.*'$/ __version__ = '$PKG_VERSION_STRICT'/ " ietf/__init__.py
92- sed -i -r -e "s/ ^__release_hash__ += '.*'$/ __release_hash__ = '$GITHUB_SHA'/ " ietf/__init__.py
93- sed -i -r -e "s/ ^__release_branch__ += '.*'$/ __release_branch__ = '$GITHUB_REF_NAME'/ " ietf/__init__.py
195+ sed -i -r -e "s| ^__version__ += '.*'$| __version__ = '$PKG_VERSION_STRICT'| " ietf/__init__.py
196+ sed -i -r -e "s| ^__release_hash__ += '.*'$| __release_hash__ = '$GITHUB_SHA'| " ietf/__init__.py
197+ sed -i -r -e "s| ^__release_branch__ += '.*'$| __release_branch__ = '$GITHUB_REF_NAME'| " ietf/__init__.py
94198 echo "Build release tarball..."
95199 mkdir -p /home/runner/work/release
96200 tar -czf /home/runner/work/release/release.tar.gz -X dev/deploy/exclude-patterns.txt .
@@ -103,6 +207,25 @@ jobs:
103207 token : ${{ github.token }}
104208 tag : ${{ env.PKG_VERSION }}
105209 writeToFile : false
210+
211+ - name : Prepare Coverage Action
212+ if : ${{ github.event.inputs.skiptests == 'false' }}
213+ working-directory : ./dev/coverage-action
214+ run : npm install
215+
216+ - name : Process Coverage Stats + Chart
217+ id : covprocess
218+ uses : ./dev/coverage-action/
219+ if : ${{ github.event.inputs.skiptests == 'false' }}
220+ with :
221+ token : ${{ github.token }}
222+ tokenCommon : ${{ secrets.GH_COMMON_TOKEN }}
223+ repoCommon : common
224+ version : ${{needs.prepare.outputs.pkg_version}}
225+ changelog : ${{ steps.changelog.outputs.changes }}
226+ summary : ${{ github.event.inputs.summary }}
227+ coverageResultsPath : coverage.json
228+ histCoveragePath : historical-coverage.json
106229
107230 - name : Create Release
108231 uses : ncipollo/release-action@v1
@@ -112,8 +235,8 @@ jobs:
112235 draft : false
113236 tag : ${{ env.PKG_VERSION }}
114237 name : ${{ env.PKG_VERSION }}
115- body : ${{ steps.changelog .outputs.changes }}
116- artifacts : " /home/runner/work/release/release.tar.gz"
238+ body : ${{ steps.covprocess .outputs.changelog }}
239+ artifacts : " /home/runner/work/release/release.tar.gz,coverage.json,historical-coverage.json "
117240 token : ${{ secrets.GITHUB_TOKEN }}
118241
119242 - name : Upload Build Artifacts
0 commit comments