Change Prettier settings (#36)

## Summary

I know this is a little tedious but I'd prefer to use the same settings
as in Ruff.
This commit is contained in:
Charlie Marsh
2024-09-05 08:06:45 -04:00
committed by GitHub
parent 1785c7bde0
commit 182c9c7e92
32 changed files with 5536 additions and 5497 deletions

View File

@ -1,65 +1,69 @@
import * as cache from '@actions/cache'
import * as glob from '@actions/glob'
import * as core from '@actions/core'
import path from 'path'
import {cacheDependencyGlob, cacheLocalPath, cacheSuffix} from '../utils/inputs'
import {getArch, getPlatform} from '../utils/platforms'
import * as cache from "@actions/cache";
import * as glob from "@actions/glob";
import * as core from "@actions/core";
import path from "path";
import {
cacheDependencyGlob,
cacheLocalPath,
cacheSuffix,
} from "../utils/inputs";
import { getArch, getPlatform } from "../utils/platforms";
export const STATE_CACHE_KEY = 'cache-key'
export const STATE_CACHE_MATCHED_KEY = 'cache-matched-key'
const CACHE_VERSION = '1'
export const STATE_CACHE_KEY = "cache-key";
export const STATE_CACHE_MATCHED_KEY = "cache-matched-key";
const CACHE_VERSION = "1";
export async function restoreCache(version: string): Promise<void> {
const cacheKey = await computeKeys(version)
const cacheKey = await computeKeys(version);
let matchedKey: string | undefined
let matchedKey: string | undefined;
core.info(
`Trying to restore uv cache from GitHub Actions cache with key: ${cacheKey}`
)
`Trying to restore uv cache from GitHub Actions cache with key: ${cacheKey}`,
);
try {
matchedKey = await cache.restoreCache([cacheLocalPath], cacheKey)
matchedKey = await cache.restoreCache([cacheLocalPath], cacheKey);
} catch (err) {
const message = (err as Error).message
core.warning(message)
core.setOutput('cache-hit', false)
return
const message = (err as Error).message;
core.warning(message);
core.setOutput("cache-hit", false);
return;
}
core.saveState(STATE_CACHE_KEY, cacheKey)
core.saveState(STATE_CACHE_KEY, cacheKey);
handleMatchResult(matchedKey, cacheKey)
handleMatchResult(matchedKey, cacheKey);
}
async function computeKeys(version: string): Promise<string> {
let cacheDependencyPathHash = '-'
if (cacheDependencyGlob !== '') {
const fullCacheDependencyGlob = `${process.env['GITHUB_WORKSPACE']}${path.sep}${cacheDependencyGlob}`
cacheDependencyPathHash += await glob.hashFiles(fullCacheDependencyGlob)
if (cacheDependencyPathHash === '-') {
let cacheDependencyPathHash = "-";
if (cacheDependencyGlob !== "") {
const fullCacheDependencyGlob = `${process.env["GITHUB_WORKSPACE"]}${path.sep}${cacheDependencyGlob}`;
cacheDependencyPathHash += await glob.hashFiles(fullCacheDependencyGlob);
if (cacheDependencyPathHash === "-") {
throw new Error(
`No file in ${process.cwd()} matched to [${cacheDependencyGlob}], make sure you have checked out the target repository`
)
`No file in ${process.cwd()} matched to [${cacheDependencyGlob}], make sure you have checked out the target repository`,
);
}
} else {
cacheDependencyPathHash += 'no-dependency-glob'
cacheDependencyPathHash += "no-dependency-glob";
}
const suffix = cacheSuffix ? `-${cacheSuffix}` : ''
return `setup-uv-${CACHE_VERSION}-${getArch()}-${getPlatform()}-${version}${cacheDependencyPathHash}${suffix}`
const suffix = cacheSuffix ? `-${cacheSuffix}` : "";
return `setup-uv-${CACHE_VERSION}-${getArch()}-${getPlatform()}-${version}${cacheDependencyPathHash}${suffix}`;
}
function handleMatchResult(
matchedKey: string | undefined,
primaryKey: string
primaryKey: string,
): void {
if (!matchedKey) {
core.info(`No GitHub Actions cache found for key: ${primaryKey}`)
core.setOutput('cache-hit', false)
return
core.info(`No GitHub Actions cache found for key: ${primaryKey}`);
core.setOutput("cache-hit", false);
return;
}
core.saveState(STATE_CACHE_MATCHED_KEY, matchedKey)
core.saveState(STATE_CACHE_MATCHED_KEY, matchedKey);
core.info(
`uv cache restored from GitHub Actions cache with key: ${matchedKey}`
)
core.setOutput('cache-hit', true)
`uv cache restored from GitHub Actions cache with key: ${matchedKey}`,
);
core.setOutput("cache-hit", true);
}