Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: updates to fix build/package & produce binaries #12284

Merged
merged 57 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
44a3438
chore: cache sample
awsluja Mar 16, 2023
8e4712e
chore: update sample cache
awsluja Mar 16, 2023
a6901af
chore: test
awsluja Mar 16, 2023
a077dae
chore: test artifacts
awsluja Mar 16, 2023
42b3dc7
chore: rename file
awsluja Mar 16, 2023
c0b222d
ci: testing s3 bucket
Mar 17, 2023
8c7842c
chore: fix build issue
Mar 17, 2023
432ec03
ci: implement caching solution
Mar 17, 2023
9f90025
ci: test
Mar 17, 2023
dba365c
ci: fix config
Mar 17, 2023
692ce51
ci: try another way to run buildlinux
Mar 17, 2023
0f33686
ci: fix path
Mar 17, 2023
aeb738c
ci: fix source
Mar 17, 2023
35a1bbe
ci: fix sh file header
Mar 17, 2023
8d9e144
ci: switch source to dot
Mar 17, 2023
ec65b42
ci: remove use of local
Mar 17, 2023
1b9d58f
ci: update s3 pathing
Mar 17, 2023
e475ee7
ci: remove function
Mar 17, 2023
986406b
ci: try again
Mar 17, 2023
cbf6afa
ci: specify bash
Mar 17, 2023
d2761c0
ci: bash test
Mar 17, 2023
bffdbfa
ci: remove parenthesis
Mar 17, 2023
f3f7981
ci: updated the cache to load
Mar 17, 2023
f34788b
ci: fix
Mar 17, 2023
0ce3ce5
ci: mute cache
Mar 17, 2023
68a8019
ci: fix
Mar 17, 2023
1b2703c
ci: update cache
Mar 20, 2023
450f132
ci: cleanup
Mar 20, 2023
5165c16
ci: add cache file method, graph updates
Mar 20, 2023
2a47d62
ci: graph updates
Mar 20, 2023
4e3ea7b
ci: rune2e sample
Mar 20, 2023
707d782
ci: yml fix
Mar 20, 2023
c45c509
ci: fix
Mar 20, 2023
4afa772
ci: fix
Mar 20, 2023
5ce53e0
ci: fix
Mar 20, 2023
4e63f65
ci: add validate
Mar 20, 2023
f81bd31
ci: fix
Mar 20, 2023
45a8eb5
ci: fix file names
Mar 20, 2023
503aeb9
ci: fix publish
Mar 21, 2023
9e2e16b
ci: test
Mar 21, 2023
5c91613
ci: fix pwd
Mar 21, 2023
a8c7b3d
ci: fix
Mar 21, 2023
a90d802
ci: fix
Mar 21, 2023
52c0be1
ci: test branch name
awsluja Mar 22, 2023
8402e59
ci: test branch
awsluja Mar 22, 2023
191870e
ci: test branch env var
awsluja Mar 22, 2023
4bdcfbf
ci: test with updated vars
awsluja Mar 22, 2023
f0ec504
ci: test env var
awsluja Mar 22, 2023
4dae2dc
ci: test env var
awsluja Mar 22, 2023
1dfa6ff
ci: re-enable and test
awsluja Mar 22, 2023
cd2a0c9
ci: try something else for publish
awsluja Mar 22, 2023
295a585
ci: test
awsluja Mar 22, 2023
b054d30
ci: try without caching verdaccio
awsluja Mar 22, 2023
28c8373
ci: try new path to verdaccio cache
awsluja Mar 22, 2023
9c36273
ci: disable sourcing invalid bash_env
awsluja Mar 22, 2023
3ef460c
ci: move env vars into correct file
awsluja Mar 22, 2023
147589d
Merge branch 'cb' into aluja/cb
aws-eddy Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .circleci/local_publish_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ default_verdaccio_package=verdaccio@5.1.2

function startLocalRegistry {
# Start local registry
tmp_registry_log=$(mktemp)
tmp_registry_log="$(mktemp)"
echo "Registry output file: $tmp_registry_log"
(cd && nohup npx ${VERDACCIO_PACKAGE:-$default_verdaccio_package} -c $1 &>$tmp_registry_log &)
# Wait for Verdaccio to boot
grep -q 'http address' <(tail -f $tmp_registry_log)
sleep 60
# grep -q 'http address' <(tail -f $tmp_registry_log)
}

function uploadPkgCli {
Expand Down
119 changes: 119 additions & 0 deletions .circleci/publish-codebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash -e

# lerna has a bug (https://github.com/lerna/lerna/issues/1066) where failed publishes do not set the exit code properly
# this causes the script to keep running even after failed publishes
# this function forces failed publishes to exit on failure
function lernaPublishExitOnFailure {
# exit on failure
set -e
# run lerna publish with the args that were passed to this function
# duplicate stdout to a temp file
# grep the temp file for the lerna err token and return exit 1 if found (-v option inverts grep exit code)
npx lerna publish "$@" | tee /tmp/publish-results && grep -qvz "lerna ERR!" < /tmp/publish-results
}

if [ -z "$GITHUB_EMAIL" ]; then
if [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then
git config --global user.email not@used.com
else
echo "GITHUB_EMAIL email is missing"
exit 1
fi
else
git config --global user.email $GITHUB_EMAIL
fi

if [ -z "$GITHUB_USER" ]; then
if [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then
git config --global user.name "Doesnt Matter"
else
echo "GITHUB_USER email is missing"
exit 1
fi
else
git config --global user.name $GITHUB_USER
fi

if [[ "$CIRCLE_BRANCH" =~ ^tagged-release ]]; then
if [[ "$CIRCLE_BRANCH" =~ ^tagged-release-without-e2e-tests\/.* ]]; then
# Remove tagged-release-without-e2e-tests/
export NPM_TAG="${CIRCLE_BRANCH/tagged-release-without-e2e-tests\//}"
elif [[ "$CIRCLE_BRANCH" =~ ^tagged-release\/.* ]]; then
# Remove tagged-release/
export NPM_TAG="${CIRCLE_BRANCH/tagged-release\//}"
fi
if [ -z "$NPM_TAG" ]; then
echo "Tag name is missing. Name your branch with either tagged-release/<tag-name> or tagged-release-without-e2e-tests/<tag-name>"
exit 1
fi

if [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then
echo "Publishing to local registry under latest tag"
lernaPublishExitOnFailure --exact --preid=$NPM_TAG --conventional-commits --conventional-prerelease --no-push --yes --include-merged-tags
else
echo "Publishing to NPM under $NPM_TAG tag"
lernaPublishExitOnFailure --exact --dist-tag=$NPM_TAG --preid=$NPM_TAG --conventional-commits --conventional-prerelease --message "chore(release): Publish tagged release $NPM_TAG [ci skip]" --yes --include-merged-tags
fi

# @latest release
elif [[ "$CIRCLE_BRANCH" == "release" ]]; then
# create release commit and release tags
npx lerna version --exact --conventional-commits --conventional-graduate --yes --no-push --include-merged-tags --message "chore(release): Publish latest [ci skip]"

# publish versions that were just computed
lernaPublishExitOnFailure from-git --yes --no-push

if [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then
echo "Published packages to verdaccio"
echo "Exiting without pushing release commit or release tags"
exit 0
fi

# push release commit
git push origin "$CIRCLE_BRANCH"

# push release tags
git tag --points-at HEAD | xargs git push origin

# fast forward main to release
git fetch origin main
git checkout main
git merge release --ff-only
git push origin main

# fast forward hotfix to release
git fetch origin hotfix
git checkout hotfix
git merge release --ff-only
git push origin hotfix

# release candidate or local publish for testing / building binary
elif [[ "$CIRCLE_BRANCH" =~ ^run-e2e-with-rc\/.* ]] || [[ "$CIRCLE_BRANCH" =~ ^release_rc\/.* ]] || [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then

# force @aws-amplify/cli-internal to be versioned in case this pipeline run does not have any commits that modify the CLI packages
if [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then
force_publish_local_args="--force-publish '@aws-amplify/cli-internal'"
fi
# create release commit and release tags
git checkout "${CODEBUILD_WEBHOOK_TRIGGER#branch/*}" && npx lerna version --preid=rc.$CODEBUILD_RESOLVED_SOURCE_VERSION --exact --conventional-prerelease --conventional-commits --yes --no-push --include-merged-tags --message "chore(release): Publish rc [ci skip]" $(echo $force_publish_local_args) --no-commit-hooks

# if publishing locally to verdaccio
if [[ "$LOCAL_PUBLISH_TO_LATEST" == "true" ]]; then
# publish to verdaccio with no dist tag (default to latest)
lernaPublishExitOnFailure from-package --git-head $CODEBUILD_RESOLVED_SOURCE_VERSION --yes --no-push
echo "Published packages to verdaccio"
echo "Exiting without pushing release commit or release tags"
exit 0
fi

# publish versions that were just computed
lernaPublishExitOnFailure from-package --git-head $CODEBUILD_RESOLVED_SOURCE_VERSION --yes --no-push --dist-tag rc

# push release commit
git push origin "${CODEBUILD_WEBHOOK_TRIGGER#branch/*}"

# push release tags
git tag --points-at HEAD | xargs git push origin
else
echo "branch name" "${CODEBUILD_WEBHOOK_TRIGGER#branch/*}" "did not match any branch publish rules. Skipping publish"
fi
70 changes: 70 additions & 0 deletions codebuild_specs/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: 0.2
env:
shell: bash
compute-type: BUILD_GENERAL1_MEDIUM
imagePullCredentialsType: SERVICE_ROLE
variables:
CLI_REGION: us-east-1
TEST_SUITE: src/__tests__/auth_2b.test.ts
AMPLIFY_DIR: '$CODEBUILD_SRC_DIR/out'
AMPLIFY_PATH: '$CODEBUILD_SRC_DIR/out/amplify-pkg-linux-x64'
# secrets-manager:
# S3_ACCESS_KEY: "secretname" # s3_access_key in secret manager

batch:
fast-fail: true
build-graph:
- identifier: build_linux
buildspec: codebuild_specs/build_linux.yml
debug-session: true
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
IS_AMPLIFY_CI: true
- identifier: test
buildspec: codebuild_specs/test.yml
debug-session: true
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
EXAMPLE_SAMPLE: 'test'
depend-on:
- build_linux
- identifier: validate_cdk_version
buildspec: codebuild_specs/validate_cdk_version.yml
debug-session: true
depend-on:
- build_linux
- identifier: verify_api_extract
buildspec: codebuild_specs/verify_api_extract.yml
debug-session: true
env:
compute-type: BUILD_GENERAL1_LARGE
depend-on:
- build_linux
- identifier: verify_yarn_lock
buildspec: codebuild_specs/verify_yarn_lock.yml
debug-session: true
depend-on:
- build_linux
- identifier: publish_to_local_registry
buildspec: codebuild_specs/publish_to_local_registry.yml
debug-session: true
env:
compute-type: BUILD_GENERAL1_LARGE
depend-on:
- build_linux
- identifier: build_pkg_binaries_linux
buildspec: codebuild_specs/build_pkg_binaries_linux.yml
debug-session: true
env:
compute-type: BUILD_GENERAL1_LARGE
depend-on:
- publish_to_local_registry
- identifier: run_e2e_tests
buildspec: codebuild_specs/run_e2e_tests.yml
debug-session: true
env:
compute-type: BUILD_GENERAL1_LARGE
depend-on:
- build_pkg_binaries_linux
11 changes: 11 additions & 0 deletions codebuild_specs/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _buildLinux

artifacts:
files:
- 'shared-scripts.sh'
11 changes: 11 additions & 0 deletions codebuild_specs/build_pkg_binaries_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _buildBinaries

artifacts:
files:
- 'shared-scripts.sh'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this. Will test on my end

7 changes: 7 additions & 0 deletions codebuild_specs/cleanup_resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- echo cleanup running
7 changes: 7 additions & 0 deletions codebuild_specs/integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- echo integration testing
7 changes: 7 additions & 0 deletions codebuild_specs/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _lint
7 changes: 7 additions & 0 deletions codebuild_specs/mock_e2e_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _mockE2ETests
11 changes: 11 additions & 0 deletions codebuild_specs/publish_to_local_registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _publishToLocalRegistry

artifacts:
files:
- 'shared-scripts.sh'
14 changes: 14 additions & 0 deletions codebuild_specs/run_e2e_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 0.2
env:
shell: bash
variables:
CLI_REGION: us-east-1
TEST_SUITE: src/__tests__/auth_2b.test.ts
AMPLIFY_DIR: $CODEBUILD_SRC_DIR/out
AMPLIFY_PATH: $CODEBUILD_SRC_DIR/out/amplify-pkg-linux-x64
phases:
build:
commands:
- echo $AMPLIFY_DIR
- echo $AMPLIFY_PATH
- source ./shared-scripts.sh && _runE2ETestsLinux
7 changes: 7 additions & 0 deletions codebuild_specs/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _testLinux
7 changes: 7 additions & 0 deletions codebuild_specs/validate_cdk_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _validateCDKVersion
7 changes: 7 additions & 0 deletions codebuild_specs/verify_api_extract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _verifyAPIExtract
7 changes: 7 additions & 0 deletions codebuild_specs/verify_yarn_lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _verifyYarnLock
Loading