Fix Windows CI + format (#767)

* Attempt to fix Windows CI:
- Ensure version 15 of LLVM is installed in Windows CI (due to` ffmpeg-sys-next`)
- Use `GITHUB_TOKEN` in setup-system.ps1 to avoid rate-limiting by github api in Windows CI
- Add `yaml` settings to `.editorconfig`
- Create a symbolic link from `.prettierignore` to `.eslintignore`
- Move `eslint` root to package root config
- Enable `fileNesting` to reduce dotfile clutter in vscode
- Pass `--strict` to apps/releases `lint` command to avoid making interactive queries and hanging `pnpm lint`
- Format with `prettier` and `eslint`
- Remove empty interface/hooks/useMediaQuery.ts

* Replace unmaintained `actions-rs/toolchain` with `dtolnay/rust-toolchain`
 - Change setup-system.ps1 to avoid installing pnpm in CI
 - Change `pnpm/action-setup` to lock only o major versions of the action
This commit is contained in:
Vítor Vasconcellos 2023-04-27 07:32:15 +00:00 committed by GitHub
parent 2623843b43
commit 164fcc34d3
16 changed files with 146 additions and 76 deletions

View File

@ -66,3 +66,8 @@ indent_style = space
[*.prisma] [*.prisma]
indent_size = 4 indent_size = 4
indent_style = space indent_style = space
# YAML
# http://yaml.org/spec/1.2/2009-07-21/spec.html#id2576668
[*.{yaml,yml}]
indent_style = space

1
.eslintignore Symbolic link
View File

@ -0,0 +1 @@
.prettierignore

View File

@ -4,7 +4,7 @@ inputs:
save-cache: save-cache:
description: Whether to save the Rust cache description: Whether to save the Rust cache
required: false required: false
default: "false" default: 'false'
runs: runs:
using: 'composite' using: 'composite'
steps: steps:

View File

@ -1,23 +1,44 @@
name: Setup name: Setup
description: Sets up runner, Rust and pnpm description: Sets up runner, Rust and pnpm
inputs: inputs:
token:
description: Github token
required: false
default: ''
save-cache: save-cache:
description: Whether to save the Rust cache description: Whether to save the Rust cache
required: false required: false
default: "false" default: 'false'
runs: runs:
using: 'composite' using: 'composite'
steps: steps:
- name: Install Rust stable - name: Install Rust
uses: actions-rs/toolchain@v1 id: toolchain
uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: stable toolchain: stable
profile: minimal components: clippy, rustfmt
- name: Install pnpm - name: Install pnpm
uses: pnpm/action-setup@v2.2.2 uses: pnpm/action-setup@v2
with: with:
version: 7.x.x version: 7.x.x
run_install: false
- name: Cache LLVM and Clang
if: runner.os == 'Windows'
id: cache-llvm
uses: actions/cache@v3
with:
path: C:/Program Files/LLVM
key: llvm-15
- name: Install LLVM and Clang
if: runner.os == 'Windows'
uses: KyleMayes/install-llvm-action@v1
with:
version: '15'
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Cache Rust deps - name: Cache Rust deps
uses: ./.github/actions/cache-rust-deps uses: ./.github/actions/cache-rust-deps
@ -33,6 +54,8 @@ runs:
shell: powershell shell: powershell
if: runner.os == 'Windows' if: runner.os == 'Windows'
run: ./.github/scripts/setup-system.ps1 run: ./.github/scripts/setup-system.ps1
env:
GITHUB_TOKEN: ${{ inputs.token }}
- name: Generate Prisma client - name: Generate Prisma client
uses: ./.github/actions/generate-prisma-client uses: ./.github/actions/generate-prisma-client

View File

@ -74,6 +74,30 @@ function Add-DirectoryToPath($directory) {
Reset-Path Reset-Path
} }
function Invoke-RestMethodGithub {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[string]$Uri,
[string]$Method = 'GET',
[hashtable]$Headers = @{},
[string]$UserAgent = 'PowerShell'
)
if (![string]::IsNullOrEmpty($env:GITHUB_TOKEN)) {
$headers.Add("Authorization", "Bearer $($env:GITHUB_TOKEN)")
}
$params = @{
Uri = $Uri
Method = $Method
Headers = $Headers
UserAgent = $UserAgent
}
Invoke-RestMethod @params
}
# Reset PATH to ensure the script doesn't read any stale entries # Reset PATH to ensure the script doesn't read any stale entries
Reset-Path Reset-Path
@ -151,7 +175,10 @@ https://learn.microsoft.com/windows/package-manager/winget/
Write-Host Write-Host
Write-Host 'Checking for pnpm...' -ForegroundColor Yellow Write-Host 'Checking for pnpm...' -ForegroundColor Yellow
if ((Get-Command pnpm -ea 0) -and (pnpm --version | Select-Object -First 1) -match "^$pnpm_major\." ) { if ($env:CI) {
# The CI has pnpm installed already
Write-Host 'Running with CI, skipping pnpm install.' -ForegroundColor Green
}if ((Get-Command pnpm -ea 0) -and (pnpm --version | Select-Object -First 1) -match "^$pnpm_major\." ) {
Write-Host "pnpm $pnpm_major is installed." -ForegroundColor Green Write-Host "pnpm $pnpm_major is installed." -ForegroundColor Green
} else { } else {
# Check for pnpm installed with standalone installer # Check for pnpm installed with standalone installer
@ -187,12 +214,8 @@ https://pnpm.io/uninstall
Write-Host Write-Host
Write-Host 'Checking for LLVM...' -ForegroundColor Yellow Write-Host 'Checking for LLVM...' -ForegroundColor Yellow
if ($env:CI) { if ($env:CI) {
# The CI has LLVM installed already, so we instead just set the env variables. # The CI has LLVM installed already
Write-Host 'Running with Ci, skipping LLVM install.' -ForegroundColor Green Write-Host 'Running with CI, skipping LLVM install.' -ForegroundColor Green
# TODO: Check if CI LLVM version match our required major version
$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n"
} elseif ( } elseif (
(Get-Command clang -ea 0) -and ( (Get-Command clang -ea 0) -and (
(clang --version | Select-String -Pattern 'version\s+(\d+)' | ForEach-Object { $_.Matches.Groups[1].Value }) -eq "$llvm_major" (clang --version | Select-String -Pattern 'version\s+(\d+)' | ForEach-Object { $_.Matches.Groups[1].Value }) -eq "$llvm_major"
@ -206,7 +229,7 @@ if ($env:CI) {
$filenamePattern = '*-win64.exe' $filenamePattern = '*-win64.exe'
Write-Host "Downloading LLVM $llvm_major installer..." -ForegroundColor Yellow Write-Host "Downloading LLVM $llvm_major installer..." -ForegroundColor Yellow
$releases = Invoke-RestMethod -Uri $releasesUri $releases = Invoke-RestMethodGithub -Uri $releasesUri
$downloadUri = $releases | ForEach-Object { $downloadUri = $releases | ForEach-Object {
if ($_.name -like $llvmVersion) { if ($_.name -like $llvmVersion) {
$_.assets | Where-Object { $_.name -like $filenamePattern } | Select-Object -ExpandProperty 'browser_download_url' $_.assets | Where-Object { $_.name -like $filenamePattern } | Select-Object -ExpandProperty 'browser_download_url'
@ -249,7 +272,7 @@ if ($protocVersion) {
$filenamePattern = '*-win64.zip' $filenamePattern = '*-win64.zip'
Write-Host 'Downloading protobuf compiler...' -ForegroundColor Yellow Write-Host 'Downloading protobuf compiler...' -ForegroundColor Yellow
$releases = Invoke-RestMethod -Uri $releasesUri $releases = Invoke-RestMethodGithub -Uri $releasesUri
for ($i = 0; $i -lt $releases.Count; $i++) { for ($i = 0; $i -lt $releases.Count; $i++) {
$release = $releases[$i] $release = $releases[$i]
foreach ($asset in $release.assets) { foreach ($asset in $release.assets) {
@ -310,7 +333,7 @@ if (($null -ne $env:FFMPEG_DIR) -and (
$filenamePattern = '*-full_build-shared.zip' $filenamePattern = '*-full_build-shared.zip'
# Downloads a build of ffmpeg from GitHub compatible with the declared ffmpeg-sys-next version # Downloads a build of ffmpeg from GitHub compatible with the declared ffmpeg-sys-next version
$releases = Invoke-RestMethod -Uri $releasesUri $releases = Invoke-RestMethodGithub -Uri $releasesUri
$version = $ffmpegVersion $version = $ffmpegVersion
while (-not ($filename -and $downloadUri) -and $version) { while (-not ($filename -and $downloadUri) -and $version) {
for ($i = 0; $i -lt $releases.Count; $i++) { for ($i = 0; $i -lt $releases.Count; $i++) {

View File

@ -25,10 +25,10 @@ jobs:
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
with: with:
save-cache: "true" save-cache: 'true'
- name: Compile (debug) - name: Compile (debug)
run: cargo test --workspace --all-features --no-run run: cargo test --workspace --all-features --no-run
- name: Compile (release) - name: Compile (release)
run: cargo test --workspace --all-features --no-run --release run: cargo test --workspace --all-features --no-run --release

View File

@ -102,6 +102,8 @@ jobs:
- name: Setup - name: Setup
uses: ./.github/actions/setup uses: ./.github/actions/setup
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Clippy - name: Run Clippy
uses: actions-rs/clippy-check@v1 uses: actions-rs/clippy-check@v1

1
.gitignore vendored
View File

@ -24,6 +24,7 @@ packages/*/node_modules
packages/*/data packages/*/data
apps/*/data apps/*/data
apps/*/stats.html apps/*/stats.html
apps/releases/.vscode
docs/public/*.st docs/public/*.st
docs/public/*.toml docs/public/*.toml
dev.db dev.db

16
.vscode/settings.json vendored
View File

@ -63,5 +63,19 @@
"packages/ui" "packages/ui"
], ],
"eslint.packageManager": "pnpm", "eslint.packageManager": "pnpm",
"eslint.lintTask.enable": true "eslint.lintTask.enable": true,
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.ts": "${capture}.js",
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
"*.jsx": "${capture}.js",
"*.tsx": "${capture}.ts",
".npmrc": ".nvmrc, .yarnrc.yml",
".gitignore": ".eslintignore, .prettierignore",
"README.md": "CONTRIBUTING.md, CODE_OF_CONDUCT.md",
"Cargo.toml": "Cargo.lock",
".eslintrc.js": ".eslintcache",
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, pnpm-workspace.yaml, .pnp.cjs, .pnp.loader.mjs",
"tsconfig.json": "tsconfig.*.json"
}
} }

View File

@ -1,8 +1,8 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
experimental: { experimental: {
appDir: true, appDir: true
}, }
} };
module.exports = nextConfig module.exports = nextConfig;

View File

@ -1,24 +1,24 @@
{ {
"name": "releases", "name": "releases",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint" "lint": "next lint --strict"
}, },
"dependencies": { "dependencies": {
"@types/node": "18.15.11", "@types/node": "18.15.11",
"@types/react": "18.0.35", "@types/react": "18.0.35",
"@types/react-dom": "18.0.11", "@types/react-dom": "18.0.11",
"@vercel/edge-config": "^0.1.7", "@vercel/edge-config": "^0.1.7",
"eslint": "^8.38.0", "eslint": "^8.38.0",
"eslint-config-next": "13.3.0", "eslint-config-next": "13.3.0",
"next": "13.3.0", "next": "13.3.0",
"octokit": "^2.0.14", "octokit": "^2.0.14",
"react": "18.2.0", "react": "18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"typescript": "5.0.4" "typescript": "5.0.4"
} }
} }

View File

@ -1,28 +1,28 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"incremental": true, "incremental": true,
"plugins": [ "plugins": [
{ {
"name": "next" "name": "next"
} }
], ],
"paths": { "paths": {
"~/*": ["./*"] "~/*": ["./*"]
} }
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }

View File

@ -6,14 +6,14 @@ import { dismissibleNoticeStore } from '~/hooks/useDismissibleNoticeStore';
import { ExplorerLayoutMode, useExplorerStore } from '~/hooks/useExplorerStore'; import { ExplorerLayoutMode, useExplorerStore } from '~/hooks/useExplorerStore';
const MediaViewIcon = () => ( const MediaViewIcon = () => (
<div className="relative mr-10 ml-3 h-14 w-14 flex-shrink-0"> <div className="relative mr-10 ml-3 h-14 w-14 shrink-0">
<img src={Image} className="absolute left-6 -top-1 h-14 w-14 rotate-6 overflow-hidden" /> <img src={Image} className="absolute left-6 -top-1 h-14 w-14 rotate-6 overflow-hidden" />
<img src={Video} className="absolute top-2 z-10 h-14 w-14 -rotate-6 overflow-hidden" /> <img src={Video} className="absolute top-2 z-10 h-14 w-14 -rotate-6 overflow-hidden" />
</div> </div>
); );
const CollectionIcon = () => ( const CollectionIcon = () => (
<div className="mr-4 ml-3 h-14 w-14 flex-shrink-0"> <div className="mr-4 ml-3 h-14 w-14 shrink-0">
<img src={Collection} /> <img src={Collection} />
</div> </div>
); );

View File

@ -52,5 +52,7 @@
"yarn": "pnpm", "yarn": "pnpm",
"node": ">=18.0.0" "node": ">=18.0.0"
}, },
"eslintConfig": {} "eslintConfig": {
"root": true
}
} }

View File

@ -1,6 +1,5 @@
const path = require('node:path'); const path = require('node:path');
module.exports = { module.exports = {
root: true,
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
parserOptions: { parserOptions: {
ecmaFeatures: { ecmaFeatures: {