Skip to content

Commit f8d7e45

Browse files
authored
ci: build improvements + skip tests option
1 parent cf5f075 commit f8d7e45

5 files changed

Lines changed: 104 additions & 82 deletions

File tree

.github/workflows/build-test-base.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
paths:
99
- 'package.json'
1010
- 'requirements.txt'
11-
- 'dev/docker-test-base/Dockerfile'
11+
- 'dev/tests/Dockerfile'
1212

1313
workflow_dispatch:
1414

@@ -32,6 +32,6 @@ jobs:
3232
image: ${{ env.IMAGE_NAME }}
3333
tags: latest
3434
registry: ${{ env.REGISTRY }}
35-
dockerfile: dev/docker-test-base/Dockerfile
35+
dockerfile: dev/tests/Dockerfile
3636
username: ${{ github.actor }}
3737
password: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build.yml

Lines changed: 86 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,84 @@ on:
1111
description: 'Create Production Release'
1212
required: true
1313
type: boolean
14+
skiptests:
15+
description: 'Skip Tests'
16+
required: true
17+
type: boolean
1418

1519
jobs:
20+
# -----------------------------------------------------------------
21+
# PREPARE
22+
# -----------------------------------------------------------------
23+
prepare:
24+
name: Prepare Release
25+
outputs:
26+
should_deploy: ${{ steps.buildvars.outputs.should_deploy }}
27+
pkg_version: ${{ steps.buildvars.outputs.pkg_version }}
28+
pkg_version_strict: ${{ steps.buildvars.outputs.pkg_version_strict }}
29+
30+
steps:
31+
- uses: actions/checkout@v2
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Get Next Version
36+
if: ${{ github.event.inputs.publish == 'true' }}
37+
id: semver
38+
uses: ietf-tools/semver-action@v1
39+
with:
40+
token: ${{ github.token }}
41+
branch: main
42+
43+
- name: Set Next Version Env Var
44+
if: ${{ github.event.inputs.publish == 'true' }}
45+
env:
46+
NEXT_VERSION: ${{ steps.semver.outputs.next }}
47+
run: |
48+
echo "NEXT_VERSION=$next" >> $GITHUB_ENV
49+
50+
- name: Create Draft Release
51+
uses: ncipollo/release-action@v1
52+
if: ${{ github.event.inputs.publish == 'true' }}
53+
with:
54+
prerelease: true
55+
draft: false
56+
commit: ${{ github.sha }}
57+
tag: ${{ env.NEXT_VERSION }}
58+
name: ${{ env.NEXT_VERSION }}
59+
body: '*pending*'
60+
token: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Set Build Variables
63+
id: buildvars
64+
run: |
65+
if [[ $NEXT_VERSION ]]; then
66+
echo "Using AUTO SEMVER mode: $NEXT_VERSION"
67+
echo "::set-output name=should_deploy::true"
68+
echo "::set-output name=pkg_version::$NEXT_VERSION"
69+
echo "::set-output name=pkg_version_strict::${NEXT_VERSION#?}"
70+
echo "::notice::Release created using branch $GITHUB_REF_NAME"
71+
elif [[ "$GITHUB_REF" =~ ^refs/tags/v* ]]; then
72+
echo "Using TAG mode: $GITHUB_REF_NAME"
73+
echo "::set-output name=should_deploy::true"
74+
echo "::set-output name=pkg_version::$GITHUB_REF_NAME"
75+
echo "::set-output name=pkg_version_strict::${GITHUB_REF_NAME#?}"
76+
echo "::notice::Release created using tag $GITHUB_REF_NAME"
77+
else
78+
echo "Using TEST mode: v7.0.0-dev.$GITHUB_RUN_NUMBER"
79+
echo "::set-output name=should_deploy::false"
80+
echo "::set-output name=pkg_version::v3.0.0-dev.$GITHUB_RUN_NUMBER"
81+
echo "::set-output name=pkg_version_strict::3.0.0-dev.$GITHUB_RUN_NUMBER"
82+
echo "::notice::Non-production build created using branch $GITHUB_REF_NAME"
83+
fi
84+
85+
# -----------------------------------------------------------------
86+
# TESTS
87+
# -----------------------------------------------------------------
1688
tests:
1789
name: Run Tests
90+
if: ${{ github.event.inputs.skiptests == 'false' }}
91+
needs: [prepare]
1892
runs-on: ubuntu-latest
1993
container: ghcr.io/ietf-tools/datatracker-test-base:latest
2094

@@ -33,20 +107,7 @@ jobs:
33107
- uses: actions/checkout@v3
34108

35109
- name: Prepare for tests
36-
run: |
37-
echo "Running containers:"
38-
docker ps -a
39-
echo "Fixing permissions..."
40-
chmod -R 777 ./
41-
echo "Copying config files..."
42-
cp ./docker/configs/settings_local.py ./ietf/settings_local.py
43-
echo "Installing NPM packages..."
44-
npm install --prefer-offline --no-audit
45-
echo "Building static assets..."
46-
npx parcel build
47-
echo "Creating data directories..."
48-
chmod +x ./docker/scripts/app-create-dirs.sh
49-
./docker/scripts/app-create-dirs.sh
110+
run: ./dev/tests/prepare.sh
50111

51112
- name: Ensure DB is ready
52113
run: |
@@ -66,65 +127,24 @@ jobs:
66127
name: coverage
67128
path: coverage.json
68129

69-
publish:
70-
needs:
71-
- tests
130+
# -----------------------------------------------------------------
131+
# RELEASE
132+
# -----------------------------------------------------------------
133+
release:
134+
name: Make Release
135+
if: ${{ always() }}
136+
needs: [tests, prepare]
72137
runs-on: ubuntu-latest
138+
env:
139+
SHOULD_DEPLOY: ${{needs.prepare.outputs.should_deploy}}
140+
PKG_VERSION: ${{needs.prepare.outputs.pkg_version}}
141+
PKG_VERSION_STRICT: ${{needs.prepare.outputs.pkg_version_strict}}
73142

74143
steps:
75144
- uses: actions/checkout@v2
76145
with:
77146
fetch-depth: 0
78147

79-
- name: Get Next Version
80-
if: ${{ github.event.inputs.publish == 'true' }}
81-
id: semver
82-
uses: ietf-tools/semver-action@v1
83-
with:
84-
token: ${{ github.token }}
85-
branch: main
86-
87-
- name: Set Next Version Env Var
88-
if: ${{ github.event.inputs.publish == 'true' }}
89-
env:
90-
NEXT_VERSION: ${{ steps.semver.outputs.next }}
91-
run: |
92-
echo "NEXT_VERSION=$next" >> $GITHUB_ENV
93-
94-
- name: Create Draft Release
95-
uses: ncipollo/release-action@v1
96-
if: ${{ github.event.inputs.publish == 'true' }}
97-
with:
98-
prerelease: true
99-
draft: false
100-
commit: ${{ github.sha }}
101-
tag: ${{ env.NEXT_VERSION }}
102-
name: ${{ env.NEXT_VERSION }}
103-
body: '*pending*'
104-
token: ${{ secrets.GITHUB_TOKEN }}
105-
106-
- name: Set Build Variables
107-
run: |
108-
if [[ $NEXT_VERSION ]]; then
109-
echo "Using AUTO SEMVER mode: $NEXT_VERSION"
110-
echo "SHOULD_DEPLOY=true" >> $GITHUB_ENV
111-
echo "PKG_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
112-
echo "PKG_VERSION_STRICT=${NEXT_VERSION#?}" >> $GITHUB_ENV
113-
echo "::notice::Release created using branch $GITHUB_REF_NAME"
114-
elif [[ "$GITHUB_REF" =~ ^refs/tags/v* ]]; then
115-
echo "Using TAG mode: $GITHUB_REF_NAME"
116-
echo "SHOULD_DEPLOY=true" >> $GITHUB_ENV
117-
echo "PKG_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV
118-
echo "PKG_VERSION_STRICT=${GITHUB_REF_NAME#?}" >> $GITHUB_ENV
119-
echo "::notice::Release created using tag $GITHUB_REF_NAME"
120-
else
121-
echo "Using TEST mode: v7.0.0-dev.$GITHUB_RUN_NUMBER"
122-
echo "SHOULD_DEPLOY=false" >> $GITHUB_ENV
123-
echo "PKG_VERSION=v3.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
124-
echo "PKG_VERSION_STRICT=3.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
125-
echo "::notice::Non-production build created using branch $GITHUB_REF_NAME"
126-
fi
127-
128148
- name: Setup Node.js
129149
uses: actions/setup-node@v3.0.0
130150
with:

.github/workflows/ci-run-tests.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,7 @@ jobs:
2929
- uses: actions/checkout@v3
3030

3131
- name: Prepare for tests
32-
run: |
33-
echo "Running containers:"
34-
docker ps -a
35-
echo "Fixing permissions..."
36-
chmod -R 777 ./
37-
echo "Copying config files..."
38-
cp ./docker/configs/settings_local.py ./ietf/settings_local.py
39-
echo "Installing NPM packages..."
40-
npm install --prefer-offline --no-audit
41-
echo "Building static assets..."
42-
npx parcel build
43-
echo "Creating data directories..."
44-
chmod +x ./docker/scripts/app-create-dirs.sh
45-
./docker/scripts/app-create-dirs.sh
32+
run: ./dev/tests/prepare.sh
4633

4734
- name: Ensure DB is ready
4835
run: |

dev/tests/prepare.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
echo "Running containers:"
4+
docker ps -a
5+
echo "Fixing permissions..."
6+
chmod -R 777 ./
7+
echo "Copying config files..."
8+
cp ./docker/configs/settings_local.py ./ietf/settings_local.py
9+
echo "Installing NPM packages..."
10+
npm install --prefer-offline --no-audit
11+
echo "Building static assets..."
12+
npx parcel build
13+
echo "Creating data directories..."
14+
chmod +x ./docker/scripts/app-create-dirs.sh
15+
./docker/scripts/app-create-dirs.sh

0 commit comments

Comments
 (0)