Skip to content

Commit

Permalink
chore(adapters): cleanup extraneous documentation in adapter and fix …
Browse files Browse the repository at this point in the history
…testing and release GHA (#10854)
  • Loading branch information
ndom91 committed May 9, 2024
1 parent fbc89ea commit 8751fa4
Show file tree
Hide file tree
Showing 31 changed files with 102 additions and 2,656 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/release.yml
Expand Up @@ -74,15 +74,15 @@ env:

jobs:
test:
name: Run release
name: Test
runs-on: ubuntu-latest
steps:
- name: Init
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
if: steps.playwright-cache.outputs.cache-hit != 'true' && github.repository == 'nextauthjs/next-auth'
run: |
pnpm exec playwright install --with-deps chromium
- name: Run Docker E2E
- name: Run E2E tests (Nextjs-Docker)
continue-on-error: true
if: false
timeout-minutes: 15
Expand Down Expand Up @@ -148,29 +148,30 @@ jobs:
name: playwright-traces
path: "**/packages/utils/test-results/*/trace.zip"
retention-days: 7
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
if: always()
name: Coverage
with:
token: ${{ secrets.CODECOV_TOKEN }}

release-branch:
name: Publish branch
timeout-minutes: 120
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' }}
environment: Production
steps:
- name: Init
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
# Please upvote https://github.com/orgs/community/discussions/13836
token: ${{ secrets.GH_PAT }}
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
cache: "pnpm"
- name: Install dependencies
Expand All @@ -183,17 +184,18 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
release-pr:
name: Publish PR
timeout-minutes: 120
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'pull_request' }}
environment: Preview
steps:
- name: Init
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
Expand Down Expand Up @@ -228,11 +230,11 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- name: Init
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
Expand Down
2 changes: 1 addition & 1 deletion apps/dev/express/src/app.ts
Expand Up @@ -56,7 +56,7 @@ app.get(
authenticatedUser,
async (_req: Request, res: Response) => {
res.json(res.locals.session)
},
}
)

app.get("/", async (_req: Request, res: Response) => {
Expand Down
6 changes: 3 additions & 3 deletions apps/examples/nextjs/Dockerfile
Expand Up @@ -7,8 +7,8 @@ RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies
COPY package.json ./
RUN npm i
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install


# Rebuild the source code only when needed
Expand Down Expand Up @@ -54,4 +54,4 @@ ENV PORT 3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD HOSTNAME="0.0.0.0" node server.js
CMD HOSTNAME="0.0.0.0" node server.js
2 changes: 1 addition & 1 deletion apps/examples/nextjs/app/[...proxy]/route.tsx
Expand Up @@ -13,7 +13,7 @@ function stripContentEncoding(result: Response) {
})
}

export async function handler(request: NextRequest) {
async function handler(request: NextRequest) {
const session = await auth()

const headers = new Headers(request.headers)
Expand Down
17 changes: 17 additions & 0 deletions apps/examples/nextjs/docker-compose.yml
@@ -0,0 +1,17 @@
version: "3"

services:
authjs-docker-test:
environment:
- TEST_KEYCLOAK_USERNAME
- TEST_KEYCLOAK_PASSWORD
- AUTH_KEYCLOAK_ID
- AUTH_KEYCLOAK_SECRET
- AUTH_KEYCLOAK_ISSUER
- AUTH_SECRET="MohY0/2zSQw/psWEnejC2ka3Al0oifvY4YjOkUaFfnI="
- AUTH_URL=http://localhost:3000/auth
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
30 changes: 30 additions & 0 deletions apps/examples/nextjs/test-docker.sh
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Easier to read `docker-compose up` output
# export BUILDKIT_PROGRESS=plain

args=("-f" "docker-compose.yml")
if [[ -z "${CI}" ]]; then
args+=("--env-file" ".env")
fi
args+=("up" "--detach" "--build")

echo "Running: docker-compose ${args[*]}"

if ! docker-compose "${args[@]}"; then
echo "Failed to start container"
exit 1
fi

echo "waiting 10 seconds for container to start..."
sleep 10

# Used to control which env vars to load in the playwright process
export TEST_DOCKER=1

# Always stop container, but exit with 1 when tests are failing
if playwright test -c ../../../packages/utils/playwright.config.ts; then
docker-compose down
else
docker-compose down && exit 1
fi
43 changes: 2 additions & 41 deletions packages/adapter-azure-tables/src/index.ts
@@ -1,6 +1,6 @@
/**
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
* <p style={{fontWeight: "300"}}>An official <a href="https://azure.microsoft.com/en-us/products/storage/tables">Azure Table Storage</a> adapter for Auth.js / NextAuth.js.</p>
* <p>An official <a href="https://azure.microsoft.com/en-us/products/storage/tables">Azure Table Storage</a> adapter for Auth.js / NextAuth.js.</p>
* <a href="https://azure.microsoft.com/en-us/products/storage/tables">
* <img style={{display: "block"}} src="/img/adapters/azure-tables.svg" width="48" />
* </a>
Expand Down Expand Up @@ -51,46 +51,7 @@ export function withoutKeys<T>(

return entity
}
/**
*
* 1. Create a table for authentication data, `auth` in the example below.
*
* ```js title="auth.ts"
* import type { AuthConfig } from "next-auth"
* import { TableStorageAdapter } from "@next-auth/azure-tables-adapter"
* import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables"
*
* const credential = new AzureNamedKeyCredential(
* process.env.AZURE_ACCOUNT,
* process.env.AZURE_ACCESS_KEY
* )
* const authClient = new TableClient(
* process.env.AZURE_TABLES_ENDPOINT,
* "auth",
* credential
* )
*
* // For more information on each option (and a full list of options) go to
* // https://authjs.dev/reference/core/types#authconfig
* export default const authConfig = {
* // https://authjs.dev/getting-started/authentication/oauth
* providers: [
* // ...
* ],
* adapter: TableStorageAdapter(authClient),
* // ...
* } satisfies AuthConfig
* ```
*
* Environment variable are as follows:
*
* ```
* AZURE_ACCOUNT=storageaccountname
* AZURE_ACCESS_KEY=longRandomKey
* AZURE_TABLES_ENDPOINT=https://$AZURE_ACCOUNT.table.core.windows.net
* ```
*
*/

export const TableStorageAdapter = (client: TableClient): Adapter => {
return {
async createUser(user) {
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-d1/src/index.ts
@@ -1,6 +1,6 @@
/**
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
* <p style={{fontWeight: "normal"}}>An official <a href="https://developers.cloudflare.com/d1/">Cloudflare D1</a> adapter for Auth.js / NextAuth.js.</p>
* <p>An official <a href="https://developers.cloudflare.com/d1/">Cloudflare D1</a> adapter for Auth.js / NextAuth.js.</p>
* <a href="https://developers.cloudflare.com/d1/">
* <img style={{display: "block"}} src="/img/adapters/d1.svg" width="48" />
* </a>
Expand Down

0 comments on commit 8751fa4

Please sign in to comment.