Skip to content

Commit

Permalink
fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
arzafran committed Nov 4, 2024
1 parent 72baa18 commit d4da350
Show file tree
Hide file tree
Showing 6 changed files with 2,901 additions and 3,155 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/automerge-github-actions-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Auto Merge Dependabot GitHub Actions Updates

on:
pull_request:
types:
- opened
- synchronize

jobs:
auto-merge:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest

permissions:
pull-requests: write
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Auto-merge Dependabot PRs
run: |
gh pr merge ${{ github.event.pull_request.number }} --squash --admin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182 changes: 160 additions & 22 deletions .github/workflows/lighthouse-on-vercel-preview-url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,187 @@ jobs:
generate_lighthouse_audit:
timeout-minutes: 5
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
actions: read

steps:
# wait arbitrary 120s for the build to finish, changes it if your builds are longer. Potential fix: https://github.com/marketplace/actions/await-for-vercel-deployment
- run: sleep 120
- name: Retrieve Vercel Project and Team Info
id: fetch_vercel_info
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: |
# Extract the repository name
project_name="${GITHUB_REPOSITORY##*/}"
echo "Using project name: $project_name"
# Fetch team info first
teams_response=$(curl -s \
-H "Authorization: Bearer $VERCEL_TOKEN" \
"https://api.vercel.com/v2/teams")
# Get the team ID for darkroom-engineering
team_id=$(echo "$teams_response" | jq -r '.teams[] | select(.slug=="darkroom-engineering") | .id')
echo "Retrieved Team ID: $team_id"
# Fetch projects using team ID
response=$(curl -s \
-H "Authorization: Bearer $VERCEL_TOKEN" \
-H "Content-Type: application/json" \
"https://api.vercel.com/v9/projects?teamId=$team_id")
# Get project ID for matching project name
project_id=$(echo "$response" | jq -r ".projects[] | select(.name==\"$project_name\") | .id")
echo "Retrieved Project ID: $project_id"
# Set environment variables
echo "VERCEL_TEAM_ID=$team_id" >> $GITHUB_ENV
echo "VERCEL_PROJECT_ID=$project_id" >> $GITHUB_ENV
- name: Capture Vercel preview URL
id: vercel_preview_url
uses: zentered/[email protected]
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
# find project id here: https://vercel.com/darkroom-engineering/satus/settings
vercel_team_id: 'darkroom-engineering'
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID }}
- uses: actions/[email protected]
vercel_team_id: ${{ env.VERCEL_TEAM_ID }}
vercel_project_id: ${{ env.VERCEL_PROJECT_ID }}

- name: Wait for Vercel Deployment
uses: UnlyEd/[email protected]
id: await-vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
deployment-url: "${{ steps.vercel_preview_url.outputs.preview_url }}"
timeout: 300 # 5 minutes timeout
poll-interval: 10
continue-on-error: true # Allow the workflow to continue even if deployment fails

- name: Check deployment status
id: deployment_check
run: |
if [ "${{ steps.await-vercel.outcome }}" == "failure" ]; then
echo "deployment_failed=true" >> $GITHUB_OUTPUT
echo "error_message=⚠️ Vercel deployment failed or timed out. Lighthouse audit could not be performed." >> $GITHUB_OUTPUT
else
echo "deployment_failed=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
if: steps.deployment_check.outputs.deployment_failed != 'true'

- name: Audit preview URL with Lighthouse
id: lighthouse_audit
if: steps.deployment_check.outputs.deployment_failed != 'true'
uses: treosh/lighthouse-ci-action@v12
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
urls: |
"https://${{ steps.vercel_preview_url.outputs.preview_url }}"
uploadArtifacts: true
temporaryPublicStorage: true

- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
const link = ${{ steps.lighthouse_audit.outputs.manifest }}[0].url
const formatResult = (res) => Math.round((res * 100))
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
const comment = [
try {
// Check if deployment failed
const deploymentFailed = '${{ steps.deployment_check.outputs.deployment_failed }}' === 'true';
if (deploymentFailed) {
core.setOutput("comment", '${{ steps.deployment_check.outputs.error_message }}');
return;
}
// Add debug logging to see the raw output
console.log('Raw lighthouse audit output:', JSON.stringify(${{ steps.lighthouse_audit.outputs.manifest }}, null, 2));
console.log('Raw links output:', JSON.stringify(${{ steps.lighthouse_audit.outputs.links }}, null, 2));
// Parse manifest with error checking
let manifest;
try {
manifest = JSON.parse(JSON.stringify(${{ steps.lighthouse_audit.outputs.manifest }}));
} catch (e) {
throw new Error(`Failed to parse manifest: ${e.message}`);
}
// Validate manifest structure
if (!manifest || !Array.isArray(manifest) || manifest.length === 0) {
throw new Error('Lighthouse manifest is invalid or empty');
}
// Get the first (and presumably only) result
const result = manifest[0].summary;
if (!result) {
console.log('Full manifest structure:', JSON.stringify(manifest, null, 2));
throw new Error('Lighthouse summary is undefined in manifest');
}
// Parse and validate links
let links;
try {
links = JSON.parse(JSON.stringify(${{ steps.lighthouse_audit.outputs.links }}));
} catch (e) {
throw new Error(`Failed to parse links: ${e.message}`);
}
if (!links) {
throw new Error('Lighthouse links are undefined');
}
if (Object.keys(links).length === 0) {
throw new Error('Lighthouse links object is empty');
}
// Helper functions
const formatResult = (res) => {
if (typeof res !== 'number') {
console.log(`Warning: Invalid result value: ${res}`);
return 0;
}
return Math.round(res * 100);
};
const score = (res) => {
const numericRes = typeof res === 'number' ? res : 0;
return numericRes >= 0.9 ? '🟢' : numericRes >= 0.5 ? '🟠' : '🔴';
};
// Generate report
const reportUrl = manifest[0].url || Object.values(links)[0];
const formattedScores = [
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this commit:`,
'',
`${score(result.performance)} Performance: ${formatResult(result.performance)}`,
`${score(result.accessibility)} Accessibility: ${formatResult(result.accessibility)}`,
`${score(result['best-practices'])} Best practices: ${formatResult(result['best-practices'])}`,
`${score(result.seo)} SEO: ${formatResult(result.seo)}`,
'',
`${score(result.performance)} Performance: ${result.performance}`,
`${score(result.accessibility)} Accessibility: ${result.accessibility}`,
`${score(result['best-practices'])} Best practices: ${result['best-practices']}`,
`${score(result.seo)} SEO: ${result.seo}`,
' ',
`*Lighthouse ran on ${link}
core.setOutput("comment", comment);
`*Lighthouse ran on [${reportUrl}](${reportUrl})*`
].join('\n');
// Set output
core.setOutput("comment", formattedScores);
} catch (error) {
// Enhanced error logging
console.error('Full error:', error);
console.error('Error stack:', error.stack);
// Set a user-friendly error message as the comment
const errorMessage = '⚠️ Failed to generate Lighthouse report. Please check the workflow logs for more details.';
core.setOutput("comment", errorMessage);
core.setFailed(`Formatting failed: ${error.message}`);
}
- name: Create commit comment
uses: peter-evans/commit-comment@v3
with:
body: |
"${{ steps.format_lighthouse_score.outputs.comment }}"
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ steps.format_lighthouse_score.outputs.comment }}
6 changes: 3 additions & 3 deletions app/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export default function manifest() {
theme_color: themes.light.contrast,
icons: [
{
src: '/icon',
src: '/icon.png',
sizes: 'any',
type: 'image/png',
},
{
src: '/icon',
src: '/icon.png',
sizes: '512x512',
type: 'image/png',
},
{
src: '/apple-icon',
src: '/apple-icon.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any',
Expand Down
1 change: 0 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import sassVars from './styles/config.js'
const nextConfig = {
reactStrictMode: true,
experimental: {
optimizeCss: true,
nextScriptWorkers: true,
webpackBuildWorker: true,
},
Expand Down
61 changes: 30 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,54 @@
"dependencies": {
"@darkroom.engineering/hamo": "0.6.46",
"@darkroom.engineering/tempus": "0.0.46",
"@next/third-parties": "^14.2.13",
"@react-three/drei": "^9.114.0",
"@react-three/fiber": "^8.17.8",
"@serwist/next": "9.0.8",
"@storyblok/js": "^3.1.4",
"@next/third-parties": "^15.0.2",
"@react-three/drei": "^9.115.0",
"@react-three/fiber": "^8.17.10",
"@serwist/next": "9.0.9",
"@storyblok/js": "^3.1.6",
"@theatre/core": "^0.7.2",
"@theatre/studio": "^0.7.2",
"clsx": "^2.1.1",
"gsap": "^3.12.5",
"lenis": "1.1.14-dev.0",
"next": "14.2.13",
"postprocessing": "^6.36.2",
"lenis": "1.1.14",
"next": "15.0.2",
"postprocessing": "^6.36.3",
"react": "18.3.1",
"react-aria-components": "^1.3.3",
"react-aria-components": "^1.4.1",
"react-dom": "18.3.1",
"sass": "^1.79.3",
"sass": "^1.80.4",
"stats-gl": "^2.2.8",
"storyblok-js-client": "^6.9.2",
"storyblok-js-client": "^6.10.1",
"storyblok-rich-text-react-renderer": "^2.9.2",
"three": "^0.168.0",
"three": "^0.169.0",
"tunnel-rat": "^0.1.2",
"zustand": "5.0.0-rc.2"
"zustand": "5.0.0"
},
"devDependencies": {
"@builder.io/partytown": "^0.10.2",
"@cerner/duplicate-package-checker-webpack-plugin": "^2.6.0",
"@chromatic-com/storybook": "2.0.2",
"@next/bundle-analyzer": "^14.2.13",
"@next/eslint-plugin-next": "^14.2.13",
"@storybook/addon-essentials": "^8.3.3",
"@storybook/addon-interactions": "^8.3.3",
"@storybook/addon-links": "^8.3.3",
"@storybook/addon-onboarding": "^8.3.3",
"@storybook/blocks": "^8.3.3",
"@storybook/nextjs": "^8.3.3",
"@storybook/react": "^8.3.3",
"@storybook/test": "^8.3.3",
"@chromatic-com/storybook": "3.2.0",
"@next/bundle-analyzer": "^15.0.2",
"@next/eslint-plugin-next": "^15.0.2",
"@storybook/addon-essentials": "^8.3.6",
"@storybook/addon-interactions": "^8.3.6",
"@storybook/addon-links": "^8.3.6",
"@storybook/addon-onboarding": "^8.3.6",
"@storybook/blocks": "^8.3.6",
"@storybook/nextjs": "^8.3.6",
"@storybook/react": "^8.3.6",
"@storybook/test": "^8.3.6",
"@svgr/webpack": "^8.1.0",
"@types/react": "^18.3.9",
"critters": "^0.0.24",
"@types/react": "^18.3.12",
"cross-env": "^7.0.3",
"eslint": "8.57.0",
"eslint-config-next": "^14.2.13",
"eslint-config-next": "^15.0.2",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-storybook": "^0.8.0",
"lefthook": "^1.7.16",
"eslint-plugin-storybook": "^0.10.1",
"lefthook": "^1.8.2",
"prettier": "^3.3.3",
"serwist": "9.0.8",
"storybook": "^8.3.3"
"serwist": "9.0.9",
"storybook": "^8.3.6"
},
"pnpm": {
"overrides": {
Expand Down
Loading

1 comment on commit d4da350

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡️ Lighthouse report for the changes in this commit:

🟢 Performance: 98
🟢 Accessibility: 90
🟢 Best practices: 96
🟠 SEO: 63

Lighthouse ran on https://satus-cqoxvqujc-darkroom-engineering.vercel.app/

Please sign in to comment.