Skip to content

Commit

Permalink
Merge branch 'rwa/main' into rwa/add-react-core-reusable-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
calebpollman authored Sep 22, 2022
2 parents 4a9dcbb + 3d30701 commit d054524
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .github/actions/log-metric/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
AWS_SECRET_ACCESS_KEY:
description: 'target AWS account credentials'
required: true
AWS_REGION:
description: 'target AWS account region'
required: true
runs:
using: 'composite'
steps:
Expand All @@ -21,6 +24,6 @@ runs:
with:
aws-access-key-id: ${{ inputs.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
aws-region: ${{ inputs.AWS_REGION }}
- shell: bash
run: aws cloudwatch put-metric-data --metric-name ${{ inputs.metric-name }} --namespace GithubCanaryApps --value ${{ inputs.value }}
37 changes: 33 additions & 4 deletions .github/workflows/publish-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

log-failure-metric:
# Send data point 1 to metric PublishLatestFailure, if it's a failure
log-failure-metric-prod:
# to be deprecated once log-failure-metric is up
# Send data point 1 to metric PublishLatestFailure in prod us-east-1, if it's a failure
runs-on: ubuntu-latest
environment: ci
needs: publish
Expand All @@ -119,9 +120,11 @@ jobs:
value: 1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1

log-success-metric:
# Send data point 0 to metric PublishLatestFailure, if it's a success
log-success-metric-prod:
# to be deprecated once log-success-metric is up
# Send data point 0 to metric PublishLatestFailure in prod us-east-1, if it's a success
runs-on: ubuntu-latest
environment: ci
needs: publish
Expand All @@ -134,3 +137,29 @@ jobs:
value: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1

log-metric:
# Send data point to metric PublishLatestFailure in github-workflows@ us-east-2
runs-on: ubuntu-latest
environment: ci
needs: publish
steps:
- name: Log failure data point to metric PublishLatestFailure
if: ${{ failure() }}
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: PublishLatestFailure
value: 1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_METRIC_LOGGER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_METRIC_LOGGER }}
AWS_REGION: us-east-2
- name: Log success data point to metric PublishLatestFailure
if: ${{ success() }}
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: PublishLatestFailure
value: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_METRIC_LOGGER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_METRIC_LOGGER }}
AWS_REGION: us-east-2
37 changes: 33 additions & 4 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ jobs:
run: yarn build
working-directory: ./canary

log-failure-metric:
# Send data point 1 to metric PublishNextFailure, if it's a failure
log-failure-metric-prod:
# to be deprecated once log-failure-metric is up
# Send data point 1 to metric PublishNextFailure in prod us-east-1, if it's a failure
runs-on: ubuntu-latest
environment: ci
needs: build-test
Expand All @@ -162,9 +163,11 @@ jobs:
value: 1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1

log-success-metric:
# Send data point 0 to metric PublishNextFailure, if it's a success
log-success-metric-prod:
# to be deprecated once log-success-metric is up
# Send data point 0 to metric PublishNextFailure in prod us-east-1, if it's a success
runs-on: ubuntu-latest
environment: ci
needs: build-test
Expand All @@ -177,3 +180,29 @@ jobs:
value: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1

log-metric:
# Send data point to metric PublishNextFailure in github-workflows@ us-east-2, if it's a failure
runs-on: ubuntu-latest
environment: ci
needs: build-test
steps:
- name: Log failure data point to metric PublishNextFailure
if: ${{ failure() }}
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: PublishNextFailure
value: 1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_METRIC_LOGGER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_METRIC_LOGGER }}
AWS_REGION: us-east-2
- name: Log success data point to metric PublishNextFailure
if: ${{ success() }}
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: PublishNextFailure
value: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_METRIC_LOGGER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_METRIC_LOGGER }}
AWS_REGION: us-east-2
37 changes: 33 additions & 4 deletions .github/workflows/run-and-test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ jobs:
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}

log-failure-metric:
# Send data point 1 to metricRunTimeTestsFailure, if it's a failure
log-failure-metric-prod:
# to be deprecated once log-failure-metric is up
# Send data point 1 to metricRunTimeTestsFailure in prod us-east-1, if it's a failure
runs-on: ubuntu-latest
environment: ci
needs: build
Expand All @@ -115,9 +116,11 @@ jobs:
value: 1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1

log-success-metric:
# Send data point 0 to metric RunTimeTestsFailure, if it's a success
log-success-metric-prod:
# to be deprecated once log-success-metric is up
# Send data point 0 to metric RunTimeTestsFailure in prod us-east-1, if it's a success
runs-on: ubuntu-latest
environment: ci
needs: build
Expand All @@ -130,3 +133,29 @@ jobs:
value: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1

log-metric:
# Send data point to metricRunTimeTestsFailure in github-workflows@ us-east-2, if it's a failure
runs-on: ubuntu-latest
environment: ci
needs: build
steps:
- name: Log failure data point to metric RunTimeTestsFailure
if: ${{ failure() }}
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: RunTimeTestsFailure
value: 1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_METRIC_LOGGER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_METRIC_LOGGER }}
AWS_REGION: us-east-2
- name: Log success data point to metric RunTimeTestsFailure
if: ${{ success() }}
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: RunTimeTestsFailure
value: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_METRIC_LOGGER }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_METRIC_LOGGER }}
AWS_REGION: us-east-2
60 changes: 60 additions & 0 deletions .github/workflows/test-rwa-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Description: This workflow runs unit + e2e tests on PRs targeting
# - `rwa/main`
# - `rwa/release`
#
# Triggered by:
# (1) Internal PRs: maintainer pushes a commit to PRs targeting those branches.
# (2) Fork PRs: maintainer adds "run-test" label to PRs targeting those branches.

name: Test / RWA / PRs

concurrency:
group: e2e-${{ github.event.pull_request.id }}
cancel-in-progress: true

on:
pull_request_target:
branches: [rwa/main, rwa/release]
types: [opened, synchronize, labeled]

permissions:
pull-requests: write # used to remove label
# other permissions are defaulted to "none"

jobs:
setup:
runs-on: ubuntu-latest
# We run tests only if it's:
# 1) pull request not from a fork (ie. internal PR), or
# 2) pull request from a fork (ie. external PR) that was added "run-tests" label
if: |
(github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event.action == 'labeled' && github.event.label.name == 'run-tests')
steps:
- name: Remove run-tests label, if applicable
if: always() && github.event.label.name == 'run-tests'
uses: actions/github-script@0.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
const label = 'run-tests';
github.issues.removeLabel({ owner, repo, issue_number, name: label });
test:
uses: aws-amplify/amplify-ui/.github/workflows/reusable-e2e.yml@rwa/main
needs: setup
with:
commit: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DOMAIN: ${{ secrets.DOMAIN }}
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }}
USERNAME: ${{ secrets.USERNAME }}
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}
SITE_URL: ${{ secrets.SITE_URL }}
DOCSEARCH_DOCS_APP_ID: ${{ secrets.DOCSEARCH_DOCS_APP_ID }}
DOCSEARCH_DOCS_API_KEY: ${{ secrets.DOCSEARCH_DOCS_API_KEY }}
DOCSEARCH_DOCS_INDEX_NAME: ${{ secrets.DOCSEARCH_DOCS_INDEX_NAME }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,54 @@ You can use the `Authenticator` component directly, or wrap your app in `withAut

<Tabs>
<TabItem title="Authenticator">
```js{3-4,11-12} file=../../../../../../examples/next/pages/ui/components/authenticator/sign-in-with-username/index.page.tsx

```js{3-4,11-12} file=../../../../../../examples/next/pages/ui/components/authenticator/sign-in-with-username/index.page.tsx

```

```
</TabItem>
<TabItem title="withAuthenticator">

The `withAuthenticator` automatically sets the [`variation`](#variation) to `modal`.

```js{3-4,9,18} file=../../../../../../examples/next/pages/ui/components/authenticator/withAuthenticator/index.page.tsx

```

`withAuthenticator` defaults the `variation` prop to `modal`.
<Tabs>
<TabItem title="Javascript">
```jsx
import { Amplify } from 'aws-amplify';

import { withAuthenticator } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';

import awsExports from './aws-exports';
Amplify.configure(awsExports);

function App({ isPassedToWithAuthenticator, signOut, user }) {
if (!isPassedToWithAuthenticator) {
throw new Error(`isPassedToWithAuthenticator was not provided`);
}

return (
<>
<h1>Hello {user.username}</h1>
<button onClick={signOut}>Sign out</button>
</>
);
}

export default withAuthenticator(App);

export async function getStaticProps() {
return {
props: {
isPassedToWithAuthenticator: true,
},
};
}
```
</TabItem>
<TabItem title="TypeScript">
```js{3-4,9,18} file=../../../../../../examples/next/pages/ui/components/authenticator/withAuthenticator/index.page.tsx

```
</TabItem>
</Tabs>
</TabItem>
</Tabs>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { Amplify } from 'aws-amplify';

import { withAuthenticator } from '@aws-amplify/ui-react';
import {
withAuthenticator,
WithAuthenticatorProps,
} from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';

import awsExports from './aws-exports';
Amplify.configure(awsExports);

function App({ isPassedToWithAuthenticator, signOut, user }) {
interface Props extends WithAuthenticatorProps {
isPassedToWithAuthenticator: boolean;
}

function App({ isPassedToWithAuthenticator, signOut, user }: Props) {
if (!isPassedToWithAuthenticator) {
throw new Error(`isPassedToWithAuthenticator was not provided`);
}
Expand Down

0 comments on commit d054524

Please sign in to comment.