Skip to content

Commit

Permalink
release(required): Amplify JS release (#12539)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc authored Nov 9, 2023
2 parents 6ac4649 + ff4e8d7 commit f1408db
Show file tree
Hide file tree
Showing 389 changed files with 4,749 additions and 3,267 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-samples-staging/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runs:
env:
BRANCH: ${{ github.ref_name }}
run: |
if git ls-remote --exit-code --heads origin $BRANCH >/dev/null 2>&1; then
if git ls-remote origin $BRANCH | grep -q refs/heads/next/$BRANCH$; then
# Branch exists, checkout and echo success message
git fetch origin $BRANCH
git checkout $BRANCH
Expand Down
32 changes: 16 additions & 16 deletions .github/integ-config/integ-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -492,22 +492,22 @@ tests:
sample_name: [delete-user]
spec: delete-user
browser: *minimal_browser_list
# - test_name: integ_next_auth_authenticator_and_ssr_page
# desc: 'Authenticator and SSR page'
# framework: next
# category: auth
# sample_name: [auth-ssr]
# spec: auth-ssr
# browser: [chrome]
# - test_name: integ_next_auth_authenticator_and_rsc_page
# desc: 'Authenticator and RSC page'
# framework: next
# category: auth
# sample_name: [auth-rsc]
# spec: auth-rsc
# browser: [chrome]
# timeout_minutes: 45
# retry_count: 10
- test_name: integ_next_auth_authenticator_and_ssr_page
desc: 'Authenticator and SSR page'
framework: next
category: auth
sample_name: [auth-ssr]
spec: auth-ssr
browser: [chrome]
- test_name: integ_next_auth_authenticator_and_rsc_page
desc: 'Authenticator and RSC page'
framework: next
category: auth
sample_name: [auth-rsc]
spec: auth-rsc
browser: [chrome]
timeout_minutes: 45
retry_count: 10

# DISABLED Angular/Vue tests:
# TODO: delete tests or add custom ui logic to support them.
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/callable-npm-publish-lts-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release LTS version to npm and update repository

on:
workflow_call:
inputs:
target:
required: true
type: string

jobs:
deploy:
name: Publish to Amplify Package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
path: amplify-js
token: ${{ secrets.GH_TOKEN_AMPLIFY_JS_WRITE }}

- name: Setup node and build the repository
uses: ./amplify-js/.github/actions/node-and-build

- name: Run npm publish
uses: ./amplify-js/.github/actions/npm-publish
with:
target: ${{ inputs.target }}
npm_token: ${{ secrets.NPM_TOKEN }}
github_user: ${{ vars.GH_USER}}
github_email: ${{ vars.GH_EMAIL}}

- name: Set github commit user
env:
GITHUB_EMAIL: ${{ vars.GH_EMAIL }}
GITHUB_USER: ${{ vars.GH_USER }}
run: |
git config --global user.email $GITHUB_EMAIL
git config --global user.name $GITHUB_USER
- name: Update API documentation
working-directory: ./amplify-js
run: |
yarn run docs
git add ./docs/api/
git commit -m "chore(release): update API docs [ci skip]"
- name: Push post release changes
working-directory: ./amplify-js
env:
TARGET_BRANCH: ${{ inputs.target }}
run: |
git push origin $TARGET_BRANCH
2 changes: 1 addition & 1 deletion .github/workflows/callable-npm-publish-preid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
ALLOW_PROTECTED_PREIDS: ${{ inputs.allow-protected-preid }}
PREID: ${{ inputs.preid }}
FORBIDDEN_PREIDS: latest
PROTECTED_PREIDS: next unstable
PROTECTED_PREIDS: next unstable stable-5 stable-4
run: |
echo "Testing to see if $PREID is in the forbidden list ($FORBIDDEN_PREIDS)"
for e in $FORBIDDEN_PREIDS; do [[ $PREID == $e ]] && echo "$PREID is forbidden from preid release" && exit 1; done
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/callable-release-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ jobs:
uses: ./.github/workflows/callable-prebuild-amplify-js.yml
with:
runs_on: ubuntu-latest
# prebuild-macos:
# uses: ./.github/workflows/callable-prebuild-amplify-js.yml
# with:
# runs_on: macos-latest
prebuild-macos:
uses: ./.github/workflows/callable-prebuild-amplify-js.yml
with:
runs_on: macos-latest
prebuild-samples-staging:
secrets: inherit
uses: ./.github/workflows/callable-prebuild-samples-staging.yml
e2e:
needs:
# - prebuild-macos
- prebuild-macos
- prebuild-ubuntu
- prebuild-samples-staging
secrets: inherit
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/push-lts-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Push - release from LTS branch to LTS dist tag

concurrency:
# group name unique for push to push-latest-release
group: push-lts-release-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- v5-stable

jobs:
e2e:
secrets: inherit
uses: ./.github/workflows/callable-release-verification.yml
release:
needs:
- e2e
permissions:
contents: write
secrets: inherit
uses: ./.github/workflows/callable-npm-publish-lts-release.yml
with:
target: v5-stable # TODO Update this to support other LTS branches in the future
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ coverage-ts/
**/example/ios/Podfile.lock
**/example/.bundle
**/example/yarn.lock

# rollup
**/.rollup.cache
**/buildMeta
5 changes: 4 additions & 1 deletion license_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"**/vendor",
"**/__tests__",
"**/__mocks__",
"**/Gemfile"
"**/Gemfile",
"**/.rollup.cache",
"**/rollup.config.mjs",
"rollup"
],
"ignoreFile": ".gitignore",
"license": "license_header.txt",
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test:duplicates": "./scripts/duplicates-yarn.sh",
"test:license": "license-check-and-add check -f license_config.json",
"test:github-actions": "node ./scripts/test-github-actions.js",
"test:tsc-compliance": "yarn workspace tsc-compliance-test test:compliance:ts4.2",
"test:tsc-compliance": "yarn workspace tsc-compliance-test test:compliance",
"coverage": "codecov || exit 0",
"docs": "typedoc packages/**/src --name amplify-js --hideGenerator --excludePrivate --ignoreCompilerErrors --mode file --out docs/api --theme docs/amplify-theme/typedoc/ --readme README.md",
"build": "lerna run build --stream && yarn test:duplicates",
Expand All @@ -30,6 +30,7 @@
"publish:preid": "./scripts/preid-env-vars-exist.sh && lerna publish --canary --force-publish --dist-tag=${PREID_PREFIX} --preid=${PREID_PREFIX}${PREID_HASH_SUFFIX} --yes",
"publish:main": "lerna publish --canary --force-publish --dist-tag=unstable --preid=unstable${PREID_HASH_SUFFIX} --yes",
"publish:release": "lerna publish from-package --dist-tag=v6 --message 'chore(release): Publish [ci skip]' --yes",
"publish:v5-stable": "lerna publish --conventional-commits --yes --dist-tag=stable-5 --message 'chore(release): Publish [ci skip]' --no-verify-access",
"publish:verdaccio": "lerna publish --canary --force-publish --no-push --dist-tag=unstable --preid=unstable --yes",
"ts-coverage": "lerna run ts-coverage",
"prepare": "./scripts/set-preid-versions.sh"
Expand Down Expand Up @@ -94,6 +95,7 @@
"babel-jest": "^24.9.0",
"babel-loader": "^8.3.0",
"codecov": "^3.6.5",
"glob": "^10.3.10",
"husky": "^3.0.5",
"jest": "^24.x.x",
"jest-config": "24.8.0",
Expand Down Expand Up @@ -129,7 +131,8 @@
"@types/babel__traverse": "7.20.0",
"path-scurry": "1.10.0",
"**/glob/minipass": "6.0.2",
"nx": "16.7.0"
"nx": "16.7.0",
"next": "13.5.6"
},
"jest": {
"resetMocks": true,
Expand Down
31 changes: 22 additions & 9 deletions packages/adapter-nextjs/__tests__/api/generateServerClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { ResourcesConfig } from '@aws-amplify/core';
import {
generateServerClientUsingCookies,
generateServerClient,
generateServerClientUsingReqRes,
} from '../../src/api';
import { runWithAmplifyServerContext } from './../../src';
import { getAmplifyConfig } from '../../src/utils';
import {
getAmplifyConfig,
createRunWithAmplifyServerContext,
} from '../../src/utils';
import { NextApiRequestMock, NextApiResponseMock } from '../mocks/headers';
import { createServerRunnerForAPI } from '../../src/api/createServerRunnerForAPI';

const headers = import('next/headers');
const headers = import('next/headers.js');
(global as any).Headers = jest.requireActual('node-fetch').Headers;

const mockAmplifyConfig: ResourcesConfig = {
Expand All @@ -29,13 +32,16 @@ const mockAmplifyConfig: ResourcesConfig = {
};

jest.mock('../../src/utils', () => ({
createRunWithAmplifyServerContext: jest.fn(() => jest.fn()),
getAmplifyConfig: jest.fn(() => mockAmplifyConfig),
createCookieStorageAdapterFromNextServerContext: jest.fn(),
}));

jest.mock('aws-amplify/adapter-core');

const mockGetAmplifyConfig = getAmplifyConfig as jest.Mock;
const mockCreateRunWithAmplifyServerContext =
createRunWithAmplifyServerContext as jest.Mock;

describe('generateServerClientUsingCookies', () => {
it('should throw error when used with req/res', async () => {
Expand All @@ -52,11 +58,13 @@ describe('generateServerClientUsingCookies', () => {
}).toThrowError();
});

it('should call getAmlifyConfig', async () => {
it('should call createRunWithAmplifyServerContext to create runWithAmplifyServerContext function', async () => {
const cookies = (await headers).cookies;

generateServerClientUsingCookies({ cookies });
expect(mockGetAmplifyConfig).toHaveBeenCalled();
generateServerClientUsingCookies({ config: mockAmplifyConfig, cookies });
expect(mockCreateRunWithAmplifyServerContext).toHaveBeenCalledWith({
config: mockAmplifyConfig,
});
});
});

Expand All @@ -67,12 +75,15 @@ describe('generateServerClient', () => {
});

it('should call getAmlifyConfig', async () => {
generateServerClient();
generateServerClientUsingReqRes({ config: mockAmplifyConfig });
expect(mockGetAmplifyConfig).toHaveBeenCalled();
});

// TODO: figure out proper mocks and unskip
it.skip('wrapped client.graphql should pass context through', async () => {
const { runWithAmplifyServerContext } = createServerRunnerForAPI({
config: mockAmplifyConfig,
});
const mockedReq = new NextApiRequestMock();
const mockedRes = NextApiResponseMock;

Expand All @@ -86,7 +97,9 @@ describe('generateServerClient', () => {
getAmplifyServerContext: () => {},
}));

const client = generateServerClient();
const client = generateServerClientUsingReqRes({
config: mockAmplifyConfig,
});

await runWithAmplifyServerContext({
nextServerContext: {
Expand Down
Loading

0 comments on commit f1408db

Please sign in to comment.