Skip to content

Commit 52bc82a

Browse files
committed
feat: Build and integ test scripts for pipeline
1 parent 8cff48f commit 52bc82a

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

buildspec.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
nodejs: 10
7+
build:
8+
commands:
9+
# Run unit tests
10+
- npm ci
11+
- npm run test
12+
artifacts:
13+
files:
14+
- '**/*'

buildspec_check_dist.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
nodejs: 10
7+
build:
8+
commands:
9+
# Validate that the dist/ folder has the latest code packaged.
10+
# If there are unpackaged changes, this build will fail.
11+
# The GitHub Actions 'package' workflow will eventually run
12+
# and will sync the dist folder, which will re-trigger this build.
13+
- npm ci
14+
- npm run package
15+
- git diff --exit-code dist/index.js
16+
artifacts:
17+
files:
18+
- '**/*'

buildspec_integ.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
GITHUB_HUB_CLI_VERSION: 2.13.0
6+
7+
phases:
8+
install:
9+
runtime-versions:
10+
nodejs: 10
11+
build:
12+
commands:
13+
# Install hub CLI
14+
- wget https://github.com/github/hub/releases/download/v$GITHUB_HUB_CLI_VERSION/hub-linux-amd64-$GITHUB_HUB_CLI_VERSION.tgz
15+
- tar -xzvf hub-linux-amd64-$GITHUB_HUB_CLI_VERSION.tgz && sudo mv hub-linux-amd64-$GITHUB_HUB_CLI_VERSION/bin/hub /usr/local/bin
16+
17+
# Configure git client
18+
- git config user.name "CodeBuild Integration Test"
19+
- git config user.email $COMMIT_EMAIL_ADDRESS
20+
- git config credential.helper "store --file=.git/credentials"
21+
- echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
22+
23+
# Run integration tests
24+
- ./run_integ_test.sh

run_integ_test.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Retrieve the action commit ID to test
6+
ACTION_GIT_COMMIT_ID=`git rev-parse HEAD`
7+
8+
# Update the integ test action workflow file with the latest action commit ID
9+
git checkout integ-tests
10+
sed -i 's|aws-actions/configure-aws-credentials@v1|aws-actions/configure-aws-credentials@$ACTION_GIT_COMMIT_ID|g' test-workflow.yml
11+
cp test-workflow.yml .github/workflows
12+
git add .github/workflows
13+
git commit -m "Test commit $ACTION_GIT_COMMIT_ID"
14+
15+
# Trigger the action workflow
16+
git push origin integ-tests
17+
18+
# Validate that the action workflow succeeds
19+
# Exit codes: success = 0; failure = 1; pending = 2; no status = 3
20+
while hub ci-status; [ $? -ge 2 ] do
21+
echo "waiting for test workflow to complete..."
22+
sleep 5
23+
done
24+
25+
hub ci-status

0 commit comments

Comments
 (0)