fix(aio): skip PWA test when redeploying non-public commit
This commit is contained in:
parent
4d523fda98
commit
06faac8b5c
|
@ -32,7 +32,8 @@ export class BuildCreator extends EventEmitter {
|
||||||
then(() => Promise.all([this.exists(prDir), this.exists(shaDir)])).
|
then(() => Promise.all([this.exists(prDir), this.exists(shaDir)])).
|
||||||
then(([prDirExisted, shaDirExisted]) => {
|
then(([prDirExisted, shaDirExisted]) => {
|
||||||
if (shaDirExisted) {
|
if (shaDirExisted) {
|
||||||
throw new UploadError(409, `Request to overwrite existing directory: ${shaDir}`);
|
const publicOrNot = isPublic ? 'public' : 'non-public';
|
||||||
|
throw new UploadError(409, `Request to overwrite existing ${publicOrNot} directory: ${shaDir}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
dirToRemoveOnError = prDirExisted ? shaDir : prDir;
|
dirToRemoveOnError = prDirExisted ? shaDir : prDir;
|
||||||
|
|
|
@ -110,6 +110,7 @@ describe('upload-server (on HTTP)', () => {
|
||||||
const authorizationHeader2 = isPublic ?
|
const authorizationHeader2 = isPublic ?
|
||||||
authorizationHeader : `--header "Authorization: ${c.BV_verify_verifiedNotTrusted}"`;
|
authorizationHeader : `--header "Authorization: ${c.BV_verify_verifiedNotTrusted}"`;
|
||||||
const cmdPrefix = curl('', `${authorizationHeader2} ${xFileHeader}`);
|
const cmdPrefix = curl('', `${authorizationHeader2} ${xFileHeader}`);
|
||||||
|
const overwriteRe = RegExp(`^Request to overwrite existing ${isPublic ? 'public' : 'non-public'} directory`);
|
||||||
|
|
||||||
|
|
||||||
it('should not overwrite existing builds', done => {
|
it('should not overwrite existing builds', done => {
|
||||||
|
@ -120,7 +121,7 @@ describe('upload-server (on HTTP)', () => {
|
||||||
expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content');
|
expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content');
|
||||||
|
|
||||||
h.runCmd(`${cmdPrefix} http://${host}/create-build/${pr}/${sha9}`).
|
h.runCmd(`${cmdPrefix} http://${host}/create-build/${pr}/${sha9}`).
|
||||||
then(h.verifyResponse(409, /^Request to overwrite existing directory/)).
|
then(h.verifyResponse(409, overwriteRe)).
|
||||||
then(() => expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content')).
|
then(() => expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content')).
|
||||||
then(done);
|
then(done);
|
||||||
});
|
});
|
||||||
|
@ -141,7 +142,7 @@ describe('upload-server (on HTTP)', () => {
|
||||||
expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content');
|
expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content');
|
||||||
|
|
||||||
h.runCmd(`${cmdPrefix} http://${host}/create-build/${pr}/${sha9Almost}`).
|
h.runCmd(`${cmdPrefix} http://${host}/create-build/${pr}/${sha9Almost}`).
|
||||||
then(h.verifyResponse(409, /^Request to overwrite existing directory/)).
|
then(h.verifyResponse(409, overwriteRe)).
|
||||||
then(() => expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content')).
|
then(() => expect(h.readBuildFile(pr, sha9, 'index.html', isPublic)).toBe('My content')).
|
||||||
then(done);
|
then(done);
|
||||||
});
|
});
|
||||||
|
@ -310,7 +311,7 @@ describe('upload-server (on HTTP)', () => {
|
||||||
expect(h.buildExists(pr, sha0, isPublic)).toBe(false);
|
expect(h.buildExists(pr, sha0, isPublic)).toBe(false);
|
||||||
|
|
||||||
uploadBuild(sha0).
|
uploadBuild(sha0).
|
||||||
then(h.verifyResponse(409, /^Request to overwrite existing directory/)).
|
then(h.verifyResponse(409, overwriteRe)).
|
||||||
then(() => {
|
then(() => {
|
||||||
checkPrVisibility(isPublic);
|
checkPrVisibility(isPublic);
|
||||||
expect(h.readBuildFile(pr, sha0, 'index.html', isPublic)).toContain(pr);
|
expect(h.readBuildFile(pr, sha0, 'index.html', isPublic)).toContain(pr);
|
||||||
|
|
|
@ -153,7 +153,8 @@ describe('BuildCreator', () => {
|
||||||
it('should abort and skip further operations if the build does already exist', done => {
|
it('should abort and skip further operations if the build does already exist', done => {
|
||||||
existsValues[shaDir] = true;
|
existsValues[shaDir] = true;
|
||||||
bc.create(pr, sha, archive, isPublic).catch(err => {
|
bc.create(pr, sha, archive, isPublic).catch(err => {
|
||||||
expectToBeUploadError(err, 409, `Request to overwrite existing directory: ${shaDir}`);
|
const publicOrNot = isPublic ? 'public' : 'non-public';
|
||||||
|
expectToBeUploadError(err, 409, `Request to overwrite existing ${publicOrNot} directory: ${shaDir}`);
|
||||||
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
||||||
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
|
@ -169,7 +170,8 @@ describe('BuildCreator', () => {
|
||||||
expect(bcExistsSpy(shaDir)).toBe(false);
|
expect(bcExistsSpy(shaDir)).toBe(false);
|
||||||
|
|
||||||
bc.create(pr, sha, archive, isPublic).catch(err => {
|
bc.create(pr, sha, archive, isPublic).catch(err => {
|
||||||
expectToBeUploadError(err, 409, `Request to overwrite existing directory: ${shaDir}`);
|
const publicOrNot = isPublic ? 'public' : 'non-public';
|
||||||
|
expectToBeUploadError(err, 409, `Request to overwrite existing ${publicOrNot} directory: ${shaDir}`);
|
||||||
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
expect(shellMkdirSpy).not.toHaveBeenCalled();
|
||||||
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
expect(bcExtractArchiveSpy).not.toHaveBeenCalled();
|
||||||
expect(bcEmitSpy).not.toHaveBeenCalled();
|
expect(bcEmitSpy).not.toHaveBeenCalled();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"interface-name": [true, "never-prefix"],
|
"interface-name": [true, "never-prefix"],
|
||||||
"max-classes-per-file": [true, 4],
|
"max-classes-per-file": [true, 4],
|
||||||
"no-consecutive-blank-lines": [true, 2],
|
"no-consecutive-blank-lines": [true, 2],
|
||||||
"no-console": false,
|
"no-console": [false],
|
||||||
"no-namespace": [true, "allow-declarations"],
|
"no-namespace": [true, "allow-declarations"],
|
||||||
"no-string-literal": false,
|
"no-string-literal": false,
|
||||||
"quotemark": [true, "single"],
|
"quotemark": [true, "single"],
|
||||||
|
|
|
@ -46,8 +46,8 @@ with a bried explanation of what they mean:
|
||||||
Request method other than POST.
|
Request method other than POST.
|
||||||
|
|
||||||
- **409 (Conflict)**:
|
- **409 (Conflict)**:
|
||||||
Request to overwrite existing directory (e.g. deploy existing build or change PR visibility when
|
Request to overwrite existing (public or non-public) directory (e.g. deploy existing build or
|
||||||
the destination directory does already exist).
|
change PR visibility when the destination directory does already exist).
|
||||||
|
|
||||||
- **413 (Payload Too Large)**:
|
- **413 (Payload Too Large)**:
|
||||||
Payload larger than size specified in `AIO_UPLOAD_MAX_SIZE`.
|
Payload larger than size specified in `AIO_UPLOAD_MAX_SIZE`.
|
||||||
|
@ -71,7 +71,8 @@ with a bried explanation of what they mean:
|
||||||
Request method other than POST.
|
Request method other than POST.
|
||||||
|
|
||||||
- **409 (Conflict)**:
|
- **409 (Conflict)**:
|
||||||
Request to overwrite existing directory (i.e. directories for both visibilities exist).
|
Request to overwrite existing (public or non-public) directory (i.e. directories for both
|
||||||
|
visibilities exist).
|
||||||
(Normally, this should not happen.)
|
(Normally, this should not happen.)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,31 +26,31 @@ readonly relevantChangedFilesCount=$(git diff --name-only $TRAVIS_COMMIT_RANGE |
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build the app
|
# Build the app
|
||||||
if [ "$skipBuild" != "true" ]; then
|
if [[ "$skipBuild" != "true" ]]; then
|
||||||
yarn build
|
yarn build
|
||||||
fi
|
fi
|
||||||
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
||||||
yarn payload-size
|
yarn payload-size
|
||||||
|
|
||||||
# Deploy to staging
|
# Deploy to staging
|
||||||
readonly httpCode=$(
|
readonly output=$(
|
||||||
curl --include --location --request POST --silent --write-out "\nHTTP_CODE: %{http_code}\n" \
|
curl --include --location --request POST --silent --write-out "\nHTTP_CODE: %{http_code}\n" \
|
||||||
--header "Authorization: Token $NGBUILDS_IO_KEY" --data-binary "@$OUTPUT_FILE" "$UPLOAD_URL" \
|
--header "Authorization: Token $NGBUILDS_IO_KEY" --data-binary "@$OUTPUT_FILE" "$UPLOAD_URL" \
|
||||||
| sed 's/\r\n/\n/' \
|
| sed 's/\r\n/\n/' \
|
||||||
| tee /dev/fd/3 \
|
| tee /dev/fd/3
|
||||||
| tail -1 \
|
|
||||||
| sed 's/HTTP_CODE: //'
|
|
||||||
)
|
)
|
||||||
|
readonly isHidden=$([[ `echo $output | grep 'non-public'` ]] && echo "true" || echo "")
|
||||||
|
readonly httpCode=$(echo "$output" | tail -1 | sed 's/HTTP_CODE: //')
|
||||||
|
|
||||||
# Exit with an error if the request failed.
|
# Exit with an error if the request failed.
|
||||||
# (Ignore 409 failures, which mean trying to re-deploy for the same PR/SHA.)
|
# (Ignore 409 failures, which mean trying to re-deploy for the same PR/SHA.)
|
||||||
if [ $httpCode -lt 200 ] || ([ $httpCode -ge 400 ] && [ $httpCode -ne 409 ]); then
|
if [[ $httpCode -lt 200 ]] || ([[ $httpCode -ge 400 ]] && [[ $httpCode -ne 409 ]]); then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run PWA-score tests (unless the deployment is not public yet;
|
# Run PWA-score tests (unless the deployment is not public yet;
|
||||||
# i.e. it could not be automatically verified).
|
# i.e. it could not be automatically verified).
|
||||||
if [ $httpCode -ne 202 ]; then
|
if [[ $httpCode -ne 202 ]] && [[ "$isHidden" != "true" ]]; then
|
||||||
yarn test-pwa-score -- "$DEPLOYED_URL" "$MIN_PWA_SCORE"
|
yarn test-pwa-score -- "$DEPLOYED_URL" "$MIN_PWA_SCORE"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue