Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/scraper/requests-2.32.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jul 25, 2024
2 parents 4cd8689 + 2a56d9b commit b9c0734
Show file tree
Hide file tree
Showing 52 changed files with 3,625 additions and 779 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ DATA_SOURCE="https://github.com/coronasafe/leaderboard-data.git"
# SLACK_EOD_BOT_SIGNING_SECRET=<Slack EOD Bot App's Signing Secret>

## -- Features -- ##
NEXT_PUBLIC_FEATURES=Leaderboard,Contributors,Feed,Releases,Projects
NEXT_PUBLIC_FEATURES=Leaderboard,Contributors,Feed,Releases,Projects,Discussions
47 changes: 40 additions & 7 deletions .github/workflows/scraper-dry-run.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Scraper Dry Run
name: Scraper Dry Run & Validate Schema

on:
workflow_dispatch:
pull_request:
paths:
- scraper/**
- tests/**
- schemas/**

jobs:
test-run-github-scraper:
Expand All @@ -12,31 +15,61 @@ jobs:
permissions:
issues: read
pull-requests: read
env:
DATA_REPO: ./
steps:
- uses: actions/checkout@v4

- name: setup python
uses: actions/setup-python@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
python-version: "3.10"
node-version: "20.14.0"

- name: Install pnpm
run: npm install -g pnpm

- name: Install dependencies
run: pip install -r scraper/requirements.txt
run: pnpm install --frozen-lockfile
working-directory: scraper

- name: Build the project
run: pnpm build
working-directory: scraper

- name: Scrape data from GitHub
run: python scraper/src/github.py ${{ github.repository_owner }} data/github -l DEBUG
run: pnpm start ${{ github.repository_owner }} ../data/github
working-directory: scraper
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: mkdir contributors

- name: Generate markdown files for new contributors
run: node scripts/generateNewContributors.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@v4
with:
name: output
retention-days: 5
path: |
data
contributors
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run Tests
run: pnpm test
40 changes: 28 additions & 12 deletions .github/workflows/scraper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ on:
slack-eod-channel:
required: false
type: string
leaderboard_ref:
required: false
type: string
default: main
description: A specific branch of scraper that is to be used.
secrets:
GIT_ACCESS_TOKEN:
required: true
SLACK_API_TOKEN:
required: false

Expand All @@ -20,35 +27,44 @@ jobs:
with:
repository: coronasafe/leaderboard
path: ./leaderboard
ref: ${{ inputs.leaderboard_ref }}
sparse-checkout: |
scraper
scripts
- name: setup python
uses: actions/setup-python@v3
- uses: actions/setup-node@v3
with:
python-version: "3.10"
node-version: "20.14.0"
- run: npm install -g pnpm

- name: Install dependencies
run: pip install -r scraper/requirements.txt
- run: pnpm install --frozen-lockfile
working-directory: scraper

- name: Scrape GitHub data
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: python scraper/src/github.py ${{ github.repository_owner }} data/github -l DEBUG
on_retry_command: git checkout .
- run: pnpm build
working-directory: scraper

- name: Scrape data from GitHub
run: pnpm start ${{ github.repository_owner }} ../../data/github
working-directory: scraper
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies
run: pip install -r scraper/requirements.txt

- name: Scrape EOD updates from Slack Channel
if: ${{ env.SLACK_API_TOKEN && env.SLACK_CHANNEL }}
run: python scraper/src/slack.py --lookback_days=2
env:
SLACK_API_TOKEN: ${{ secrets.SLACK_API_TOKEN }}
SLACK_CHANNEL: ${{ inputs.slack-eod-channel }}

- run: mkdir -p contributors

- name: Generate markdown files for new contributors
run: node scripts/generateNewContributors.js
env:
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
.pnp.js
bun.lockb
package-lock.json
pnpm-lock.yaml

# testing
/coverage
Expand Down Expand Up @@ -43,4 +42,7 @@ data-repo

# Package Lock
package-lock.json
yarn.lock
yarn.lock

# Files placed by data-repo
/public/logo.png
18 changes: 9 additions & 9 deletions activities-bot/src/sendReminder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ const remind = async ({ slackId, updates }) => {
const formatUpdatesMessage = (updates) => {
if (updates?.length) {
return `
Here are your updates for today:
${updates.map((update, i) => `${i + 1}. ${update}`).join("\n")}
_If you wish to add more updates, *send each of the update as an individual message*._
_If you wish to clear or re-write your updates, message *\`clear updates\`*._
_These updates will be sent to the channel at the end of the working day along with your contribution data from GitHub._
Here are your updates for today:
${updates.map((update, i) => `${i + 1}. ${update}`).join("\n")}
_If you wish to add more updates, *send each of the update as an individual message*._
_If you wish to clear or re-write your updates, message *\`clear updates\`*._
_These updates will be sent to the channel at the end of the working day along with your contribution data from GitHub._
`;
}

return `
You have not specified any EOD updates for today.
If you wish to add updates, *send each of the update as an individual message*.`;
You have not specified any EOD updates for today.
If you wish to add updates, *send each of the update as an individual message*.`;
};

async function main() {
Expand Down
7 changes: 6 additions & 1 deletion app/api/leaderboard/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const getLeaderboardData = async (
.filter(
(contributor) => roles.length == 0 || roles.includes(contributor.role),
)
.filter((contributor) => {
if (sortBy) {
return contributor.summary[sortBy] ?? 0 > 0;
}
})
.sort((a, b) => {
if (sortBy === "pr_stale") {
return b.activityData.pr_stale - a.activityData.pr_stale;
Expand Down Expand Up @@ -55,7 +60,7 @@ export const getLeaderboardData = async (
},
highlights: {
...contributor.summary,
pr_stale: contributor.activityData.pr_stale,
pr_stale: contributor.activityData.pr_stale ?? 0,
},
};
});
Expand Down
2 changes: 1 addition & 1 deletion app/contributors/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BadgeIcons from "../../../components/contributors/BadgeIcons";
import GithubActivity from "../../../components/contributors/GithubActivity";
import GraduateAttributeBadge from "../../../components/contributors/GraduateAttributeBadge";
import InfoCard from "../../../components/contributors/InfoCard";
import React, { Suspense } from "react";
import React from "react";
import clsx from "clsx";
import { formatDuration, parseDateRangeSearchParam } from "@/lib/utils";
import Markdown from "@/components/Markdown";
Expand Down
15 changes: 15 additions & 0 deletions app/contributors/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { sitemapEntry } from "@/app/sitemap";
import { getContributors } from "@/lib/api";
import { MetadataRoute } from "next";

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const contriutors = await getContributors();
return contriutors.map((contributor) =>
sitemapEntry(`/contributors/${contributor.github}`, {
lastModified: contributor.activityData.last_updated
? new Date(contributor.activityData.last_updated)
: undefined,
priority: 0.8,
}),
);
}
35 changes: 35 additions & 0 deletions app/discussions/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Metadata } from "next";
import { env } from "@/env.mjs";
import { notFound } from "next/navigation";
import { featureIsEnabled } from "@/lib/utils";
import FilterDiscussions from "../../components/discussions/FilterDiscussions";
import { categories } from "../../lib/discussion";
import DiscussionLeaderboard from "../../components/discussions/DiscussionLeaderboard";
import { Suspense } from "react";

export const metadata: Metadata = {
title: `Disucssions | ${env.NEXT_PUBLIC_PAGE_TITLE}`,
};

export default function DiscussionsLayout({
children,
}: {
children: React.ReactNode;
}) {
if (!featureIsEnabled("Discussions")) return notFound();

return (
<div className="mx-auto max-w-6xl p-5">
<div className="items-center gap-5 pb-8 lg:mt-10 lg:flex">
<h1 className="text-3xl sm:text-4xl">Disucssions</h1>
<Suspense fallback={<></>}>
<FilterDiscussions categories={categories} />
</Suspense>
</div>
<div className="flex w-full flex-col-reverse gap-3 lg:flex lg:flex-row">
{children}
<DiscussionLeaderboard />
</div>
</div>
);
}
19 changes: 19 additions & 0 deletions app/discussions/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { fetchGithubDiscussion } from "../../lib/discussion";
import GithubDiscussions from "../../components/discussions/GithubDiscussions";

interface Params {
searchParams: { [key: string]: string };
}

export default async function Page({ searchParams }: Params) {
const discussions = await fetchGithubDiscussion();

return (
discussions && (
<GithubDiscussions
discussions={discussions}
searchParams={searchParams}
/>
)
);
}
6 changes: 0 additions & 6 deletions app/issues/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { env } from "@/env.mjs";
import octokit from "@/lib/octokit";
import Image from "next/image";
import Link from "next/link";
import { GoIssueOpened } from "react-icons/go";
import Markdown from "@/components/Markdown";
import ActiveProjects from "../projects/ActiveProjects";

const page = async () => {
Expand Down
2 changes: 1 addition & 1 deletion app/leaderboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function LeaderboardPage({ searchParams }: PageProps) {
const keyString = `search=${searchParams?.search}`;
return (
<section className="border-t border-secondary-300 bg-background text-foreground dark:border-secondary-700">
<div className="mx-auto max-w-6xl">
<div className="mx-auto max-w-7xl">
<Searchbar searchParams={searchParams} />
<div className="mx-4 border-secondary-600 xl:mx-0">
<Suspense
Expand Down
32 changes: 30 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { env } from "@/env.mjs";
import CommunityEngagemet from "@/app/CommunityEngagementSummary";
import { differenceInWeeks, parseISO } from "date-fns";
import { featureIsEnabled, formatDate } from "@/lib/utils";
import { fetchGithubDiscussion } from "../lib/discussion";
import GithubDiscussion from "@/components/discussions/GithubDiscussion";

export default async function Home() {
const contributors = (await getContributors())
Expand All @@ -21,7 +23,7 @@ export default async function Home() {
.includes(contributor.role) ?? true,
)
.sort((a, b) => b.weekSummary.points - a.weekSummary.points);

const discussions = await fetchGithubDiscussion(5);
const startDate = parseISO(env.NEXT_PUBLIC_ORG_START_DATE);

return (
Expand Down Expand Up @@ -95,7 +97,33 @@ export default async function Home() {
</div>
</div>
)}

{discussions && (
<div className="mx-auto">
<div className="space-y-12">
<div className="flex items-center justify-between pr-2">
<h2 className="text-3xl font-bold tracking-tight sm:text-4xl">
Discussions
</h2>
<Link
href="/discussions"
className="flex items-center gap-1 rounded p-2 text-secondary-400 underline underline-offset-2 transition-all duration-200 ease-in-out hover:gap-2 hover:text-primary-200"
>
More
<MdOutlineArrowForwardIos />
</Link>
</div>
{discussions.map((discussion, index) => {
return (
<GithubDiscussion
key={index}
discussion={discussion}
minimal
/>
);
})}
</div>
</div>
)}
{featureIsEnabled("Projects") && (
<div className="mx-auto">
<div className="space-y-12">
Expand Down
Loading

0 comments on commit b9c0734

Please sign in to comment.