Skip to content

Commit 630562a

Browse files
authored
Merge branch 'develop' into revanth/sidebar-posts
2 parents bde2968 + d45d070 commit 630562a

File tree

19 files changed

+2186
-658
lines changed

19 files changed

+2186
-658
lines changed

.github/workflows/alt-text-bot.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: Accessibility-alt-text-bot
1+
name: Accessibility Alt Text Bot
2+
23
on:
34
issues:
45
types: [opened, edited]
@@ -11,15 +12,19 @@ on:
1112
discussion_comment:
1213
types: [created, edited]
1314

15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number || github.event.discussion.number || github.ref }}
17+
cancel-in-progress: true
18+
1419
permissions:
1520
issues: write
1621
pull-requests: write
1722
discussions: write
1823

1924
jobs:
2025
accessibility_alt_text_bot:
21-
name: Check alt text is set on issue or pull requests
26+
name: Check alt text on issues and pull requests
2227
runs-on: ubuntu-latest
2328
steps:
24-
- name: Get action 'github/accessibility-alt-text-bot'
25-
uses: github/[email protected] # Set to latest
29+
- name: Run Alt Text Bot
30+
uses: github/[email protected]

.github/workflows/e2e-tests.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request_target:
8+
types: [opened, synchronize, reopened]
9+
branches:
10+
- develop
11+
12+
# Cancel old builds on new commit for same workflow + branch/PR
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
initial-checks:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.event.pull_request.head.sha }}
25+
fetch-depth: 0
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 'lts/*'
31+
cache: 'npm'
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
e2e:
37+
needs: initial-checks
38+
runs-on: ubuntu-latest
39+
environment: production
40+
41+
env:
42+
DATABASE_URL: "postgresql://postgres:secret@localhost:5432/postgres"
43+
NEXTAUTH_URL: http://localhost:3000/api/auth
44+
GITHUB_ID: ${{ secrets.E2E_GITHUB_ID }}
45+
GITHUB_SECRET: ${{ secrets.E2E_GITHUB_SECRET }}
46+
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
with:
52+
ref: ${{ github.event.pull_request.head.sha }}
53+
fetch-depth: 0
54+
55+
- name: Setup Node.js
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: 'lts/*'
59+
cache: 'npm'
60+
61+
- name: Cache Playwright browsers
62+
uses: actions/cache@v3
63+
with:
64+
path: ~/.cache/ms-playwright
65+
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
66+
restore-keys: |
67+
${{ runner.os }}-playwright-
68+
69+
- name: Run docker-compose
70+
uses: isbang/[email protected]
71+
with:
72+
compose-file: "./docker-compose.yml"
73+
down-flags: "--volumes"
74+
services: |
75+
db
76+
77+
- name: Wait for DB to be ready
78+
run: |
79+
timeout 60s bash -c 'until nc -z localhost 5432; do echo "Waiting for database connection..."; sleep 2; done'
80+
shell: bash
81+
82+
- name: Install dependencies
83+
run: npm ci
84+
85+
- name: Install Playwright browsers
86+
run: npx playwright install --with-deps
87+
if: steps.playwright-cache.outputs.cache-hit != 'true'
88+
89+
- name: Seed database
90+
run: |
91+
npm run db:push
92+
npm run db:seed
93+
94+
- name: Run Playwright tests
95+
id: playwright-tests
96+
run: npx playwright test
97+
continue-on-error: true
98+
99+
- name: Upload Playwright report
100+
uses: actions/upload-artifact@v4
101+
if: always()
102+
with:
103+
name: playwright-report
104+
path: playwright-report/
105+
retention-days: 30
106+
107+
- name: Check test results
108+
if: steps.playwright-tests.outcome == 'failure'
109+
run: exit 1

.github/workflows/greetings.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ on:
66
pull_request_target:
77
types: [opened]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
welcome-new-contributor:
1115
runs-on: ubuntu-latest
16+
permissions:
17+
issues: write
18+
pull-requests: write
1219
steps:
1320
- name: 'Greet the contributor'
1421
uses: garg3133/[email protected]
1522
with:
1623
token: ${{ secrets.GITHUB_TOKEN }}
17-
issue-message: 'Hello @contributor_name, thanks for opening your first issue! your contribution is valuable to us. The maintainers will review this issue and provide feedback as soon as possible.'
18-
pr-message: 'Hello @contributor_name, thanks for opening your first Pull Request. The maintainers will review this Pull Request and provide feedback as soon as possible. Keep up the great work!'
24+
issue-message: 'Hello @{{ contributor }}, thanks for opening your first issue! Your contribution is valuable to us. The maintainers will review this issue and provide feedback as soon as possible.'
25+
pr-message: 'Hello @{{ contributor }}, thanks for opening your first Pull Request. The maintainers will review this Pull Request and provide feedback as soon as possible. Keep up the great work!'

.github/workflows/pull-request.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1-
name: Check the pull request
1+
name: Code Quality Checks
22

33
on:
44
pull_request:
55
types: [opened, synchronize, reopened, edited]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
8-
check-pull-request:
9-
name: Check code styling and run tests
12+
lint-and-format:
13+
name: Run ESLint and Prettier
1014
runs-on: ubuntu-latest
1115
steps:
1216
- name: Checkout source code
1317
uses: actions/checkout@v4
14-
- name: Use the correct Node.js version
18+
19+
- name: Use Node.js
1520
uses: actions/setup-node@v4
1621
with:
17-
node-version: "20.17.0"
22+
node-version: 'lts/*'
23+
cache: 'npm'
24+
1825
- name: Install dependencies
1926
run: npm ci
27+
2028
- name: Run ESLint
2129
run: npm run lint
30+
2231
- name: Run Prettier
2332
run: npm run prettier
33+
34+
- name: Check for uncommitted changes
35+
run: |
36+
git diff --exit-code || \
37+
(echo "Detected uncommitted changes after build. See status below:" && \
38+
git diff && \
39+
exit 1)

app/(app)/[username]/_usernameClient.tsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { LinkIcon } from "@heroicons/react/20/solid";
88
import { api } from "@/server/trpc/react";
99
import { useRouter, useSearchParams } from "next/navigation";
1010
import type { Session } from "next-auth";
11-
import { Tabs } from "@/components/Tabs";
11+
import { Heading } from "@/components/ui-components/heading";
1212
import { toast } from "sonner";
1313

1414
type Props = {
@@ -71,20 +71,8 @@ const Profile = ({ profile, isOwner, session }: Props) => {
7171
}
7272
};
7373

74-
const selectedTab =
75-
tabFromParams && ["groups", "articles"].includes(tabFromParams)
76-
? tabFromParams
77-
: "articles";
78-
79-
const [ARTICLES] = ["articles"];
80-
const tabs = [
81-
{
82-
name: `Articles (${posts.length})`,
83-
value: ARTICLES,
84-
href: `?tab=${ARTICLES}`,
85-
current: selectedTab === ARTICLES,
86-
},
87-
];
74+
const ARTICLES = "articles";
75+
const selectedTab = tabFromParams === ARTICLES ? ARTICLES : ARTICLES;
8876

8977
return (
9078
<>
@@ -121,11 +109,11 @@ const Profile = ({ profile, isOwner, session }: Props) => {
121109
</main>
122110
{accountLocked ? (
123111
<div className="mt-8 flex items-center justify-between border-b pb-4 text-3xl font-extrabold tracking-tight text-neutral-900 dark:text-neutral-50 sm:text-4xl">
124-
<h1>Account locked 🔒</h1>
112+
<Heading level={1}>Account locked 🔒</Heading>
125113
</div>
126114
) : (
127-
<div className="mx-auto mt-4 dark:bg-neutral-900 sm:max-w-2xl lg:max-w-5xl">
128-
<Tabs tabs={tabs} />
115+
<div className="mx-auto mt-4 sm:max-w-2xl lg:max-w-5xl">
116+
<Heading level={1}>{`Articles (${posts.length})`}</Heading>
129117
</div>
130118
)}
131119
{(() => {
@@ -179,10 +167,6 @@ const Profile = ({ profile, isOwner, session }: Props) => {
179167
)}
180168
</div>
181169
);
182-
case GROUPS:
183-
return (
184-
<p className="py-4 font-medium">Groups are coming soon!</p>
185-
);
186170
default:
187171
return null;
188172
}

app/(app)/[username]/page.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ export default async function Page({
8080
),
8181
orderBy: (posts, { desc }) => [desc(posts.published)],
8282
},
83-
BannedUsers: {
84-
columns: {
85-
id: true,
86-
},
87-
},
8883
},
8984
where: (users, { eq }) => eq(users.username, username),
9085
});
@@ -93,22 +88,16 @@ export default async function Page({
9388
notFound();
9489
}
9590

96-
const accountLocked = !!profile.BannedUsers;
91+
const bannedUser = await db.query.banned_users.findFirst({
92+
where: (bannedUsers, { eq }) => eq(bannedUsers.userId, profile.id),
93+
});
94+
95+
const accountLocked = !!bannedUser;
9796
const session = await getServerAuthSession();
9897
const isOwner = session?.user?.id === profile.id;
9998

100-
type MakeOptional<Type, Key extends keyof Type> = Omit<Type, Key> &
101-
Partial<Type>;
102-
103-
type Profile = typeof profile;
104-
const cleanedProfile: MakeOptional<Profile, "BannedUsers"> = {
105-
...profile,
106-
};
107-
108-
delete cleanedProfile.BannedUsers;
109-
11099
const shapedProfile = {
111-
...cleanedProfile,
100+
...profile,
112101
posts: accountLocked
113102
? []
114103
: profile.posts.map((post) => ({

0 commit comments

Comments
 (0)