mirror of
https://github.com/ivabus/pantry
synced 2024-11-30 04:05:06 +03:00
use actions/cache to reduce deno.land 500s
This commit is contained in:
parent
1926eafcbf
commit
63632639a0
5 changed files with 117 additions and 69 deletions
40
.github/workflows/bottle.yml
vendored
40
.github/workflows/bottle.yml
vendored
|
@ -15,11 +15,16 @@ jobs:
|
||||||
get-platform:
|
get-platform:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
os: ${{ steps.platform.outputs.OS }}
|
os: ${{ steps.platform.outputs.os }}
|
||||||
|
cache-set: ${{ steps.platform.outputs.cache-set }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: teaxyz/pantry.core
|
repository: teaxyz/pantry.core
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: $HOME/.cache/deno
|
||||||
|
key: ${{ runner.os }}-deno-deps
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
- run: scripts/get-platform.ts ${{ inputs.projects }}
|
- run: scripts/get-platform.ts ${{ inputs.projects }}
|
||||||
id: platform
|
id: platform
|
||||||
|
@ -37,15 +42,10 @@ jobs:
|
||||||
built: ${{ env.built }}
|
built: ${{ env.built }}
|
||||||
pr: ${{ env.PR }}
|
pr: ${{ env.PR }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: tea.xyz/var/cli
|
path: ${{ needs.get-platform.outputs.cache-set }}
|
||||||
repository: teaxyz/cli
|
key: ${{ runner.os }}-deno-deps
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: pantry
|
|
||||||
|
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
id: tea
|
id: tea
|
||||||
with:
|
with:
|
||||||
|
@ -53,7 +53,7 @@ jobs:
|
||||||
prefix: ${{ github.workspace }}
|
prefix: ${{ github.workspace }}
|
||||||
|
|
||||||
- name: configure scripts PATH
|
- name: configure scripts PATH
|
||||||
run: echo "$PWD/scripts:$TEA_PREFIX/tea.xyz/var/pantry/scripts" >> $GITHUB_PATH
|
run: echo "$TEA_PREFIX/tea.xyz/var/pantry/scripts" >> $GITHUB_PATH
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
if: ${{ inputs.new-version }}
|
if: ${{ inputs.new-version }}
|
||||||
|
@ -61,7 +61,7 @@ jobs:
|
||||||
name: ${{ inputs.platform }}
|
name: ${{ inputs.platform }}
|
||||||
path: tea.xyz/var/pantry
|
path: tea.xyz/var/pantry
|
||||||
|
|
||||||
- run: scripts/fetch-pr-artifacts.ts ${{ github.repository }} ${{ github.sha }} ${{ inputs.platform }} >>$GITHUB_ENV
|
- run: fetch-pr-artifacts.ts ${{ github.repository }} ${{ github.sha }} ${{ inputs.platform }} >>$GITHUB_ENV
|
||||||
if: ${{ !inputs.new-version }}
|
if: ${{ !inputs.new-version }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{github.token}}
|
GITHUB_TOKEN: ${{github.token}}
|
||||||
|
@ -124,14 +124,14 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
|
|
||||||
- run: scripts/bottle.ts $built
|
- run: bottle.ts $built
|
||||||
id: bottle-xz
|
id: bottle-xz
|
||||||
env:
|
env:
|
||||||
COMPRESSION: xz
|
COMPRESSION: xz
|
||||||
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
|
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
|
||||||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||||
|
|
||||||
- run: scripts/bottle.ts $built
|
- run: bottle.ts $built
|
||||||
id: bottle-gz
|
id: bottle-gz
|
||||||
env:
|
env:
|
||||||
COMPRESSION: gz
|
COMPRESSION: gz
|
||||||
|
@ -167,14 +167,10 @@ jobs:
|
||||||
run:
|
run:
|
||||||
working-directory: tea.xyz/var/pantry
|
working-directory: tea.xyz/var/pantry
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: tea.xyz/var/cli
|
path: $HOME/.cache/deno
|
||||||
repository: teaxyz/cli
|
key: ${{ runner.os }}-deno-deps
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: pantry
|
|
||||||
|
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
id: tea
|
id: tea
|
||||||
|
@ -195,11 +191,11 @@ jobs:
|
||||||
working-directory: ${{ steps.tea.outputs.prefix }}
|
working-directory: ${{ steps.tea.outputs.prefix }}
|
||||||
|
|
||||||
- name: configure scripts PATH
|
- name: configure scripts PATH
|
||||||
run: echo "$PWD/scripts:$TEA_PREFIX/tea.xyz/var/pantry/scripts" >> $GITHUB_PATH
|
run: echo "$TEA_PREFIX/tea.xyz/var/pantry/scripts" >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: upload bottles
|
- name: upload bottles
|
||||||
id: upload
|
id: upload
|
||||||
run: scripts/upload.ts
|
run: upload.ts
|
||||||
--pkgs ${{ needs.bottle.outputs.built }} ${{ needs.bottle.outputs.built }}
|
--pkgs ${{ needs.bottle.outputs.built }} ${{ needs.bottle.outputs.built }}
|
||||||
--srcs ${{ needs.bottle.outputs.srcs }} ${{ needs.bottle.outputs.srcs }}
|
--srcs ${{ needs.bottle.outputs.srcs }} ${{ needs.bottle.outputs.srcs }}
|
||||||
--bottles $bottles
|
--bottles $bottles
|
||||||
|
|
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
|
@ -22,10 +22,15 @@ jobs:
|
||||||
build-os: ${{ steps.platform.outputs.build-os }}
|
build-os: ${{ steps.platform.outputs.build-os }}
|
||||||
container: ${{ steps.platform.outputs.container }}
|
container: ${{ steps.platform.outputs.container }}
|
||||||
test-matrix: ${{ steps.platform.outputs.test-matrix }}
|
test-matrix: ${{ steps.platform.outputs.test-matrix }}
|
||||||
|
cache-set: ${{ steps.platform.outputs.cache-set }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: teaxyz/pantry.core
|
repository: teaxyz/pantry.core
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: $HOME/.cache/deno
|
||||||
|
key: ${{ runner.os }}-deno-deps
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
- run: scripts/get-platform.ts ${{ inputs.projects }}
|
- run: scripts/get-platform.ts ${{ inputs.projects }}
|
||||||
id: platform
|
id: platform
|
||||||
|
@ -39,7 +44,10 @@ jobs:
|
||||||
needs: [get-platform]
|
needs: [get-platform]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ needs.get-platform.outputs.cache-set }}
|
||||||
|
key: ${{ runner.os }}-deno-deps
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
id: tea
|
id: tea
|
||||||
with:
|
with:
|
||||||
|
@ -104,6 +112,10 @@ jobs:
|
||||||
container: ${{ matrix.platform.container }}
|
container: ${{ matrix.platform.container }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ needs.get-platform.outputs.cache-set }}
|
||||||
|
key: ${{ runner.os }}-deno-deps
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
|
|
||||||
- name: configure scripts PATH
|
- name: configure scripts PATH
|
||||||
|
@ -151,6 +163,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: $HOME/.cache/deno
|
||||||
|
key: ${{ runner.os }}-deno-deps
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
|
|
||||||
- name: configure scripts PATH
|
- name: configure scripts PATH
|
||||||
|
|
4
.github/workflows/cd.yml
vendored
4
.github/workflows/cd.yml
vendored
|
@ -11,6 +11,10 @@ jobs:
|
||||||
HAS_ARTIFACTS: ${{ env.HAS_ARTIFACTS }}
|
HAS_ARTIFACTS: ${{ env.HAS_ARTIFACTS }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: $HOME/.cache/deno
|
||||||
|
key: ${{ runner.os }}-deno-deps
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
- run: ./scripts/map-projects-to-githubs.ts
|
- run: ./scripts/map-projects-to-githubs.ts
|
||||||
env:
|
env:
|
||||||
|
|
4
.github/workflows/index-data.yml
vendored
4
.github/workflows/index-data.yml
vendored
|
@ -12,6 +12,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: $HOME/.cache/deno
|
||||||
|
key: ${{ runner.os }}-deno-deps
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
- run: ./scripts/index-packages.ts ${{ inputs.projects }}
|
- run: ./scripts/index-packages.ts ${{ inputs.projects }}
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -11,56 +11,84 @@ args:
|
||||||
|
|
||||||
import { panic } from "utils";
|
import { panic } from "utils";
|
||||||
|
|
||||||
const platform = Deno.env.get("PLATFORM") ?? panic("$PLATFORM not set")
|
type Output = {
|
||||||
|
os: OS,
|
||||||
let os: string | string[]
|
buildOs: OS,
|
||||||
let buildOs: string | string[]
|
container?: string,
|
||||||
let container: string | undefined
|
testMatrix: { os: OS, container?: string }[]
|
||||||
let testMatrix: { os: string | string[], container: string | undefined }[]
|
cacheSet: string
|
||||||
|
|
||||||
switch(platform) {
|
|
||||||
case "darwin+x86-64":
|
|
||||||
os = "macos-11"
|
|
||||||
// Using GHA resources for now, until we resolve network issues with our runners
|
|
||||||
// buildOs = ["self-hosted", "macOS", "X64"]
|
|
||||||
buildOs = os
|
|
||||||
testMatrix = [{ os, container: undefined }]
|
|
||||||
break
|
|
||||||
case "darwin+aarch64":
|
|
||||||
os = ["self-hosted", "macOS", "ARM64"]
|
|
||||||
buildOs = os
|
|
||||||
testMatrix = [{ os, container: undefined }]
|
|
||||||
break
|
|
||||||
case "linux+aarch64":
|
|
||||||
os = ["self-hosted", "linux", "ARM64"]
|
|
||||||
buildOs = os
|
|
||||||
testMatrix = [{ os, container: undefined }]
|
|
||||||
break
|
|
||||||
case "linux+x86-64":
|
|
||||||
os = "ubuntu-latest"
|
|
||||||
// Using GHA resources for now, until we resolve network issues with our runners
|
|
||||||
// buildOs = ["self-hosted", "linux", "X64"]
|
|
||||||
buildOs = os
|
|
||||||
container = "ghcr.io/teaxyz/infuser:latest"
|
|
||||||
testMatrix = [
|
|
||||||
{ os, container: undefined },
|
|
||||||
// { os: buildOs, container: undefined },
|
|
||||||
{ os, container },
|
|
||||||
{ os, container: "debian:buster-slim" },
|
|
||||||
]
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
panic(`Invalid platform description: ${platform}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = `os=${JSON.stringify(os)}\n` +
|
type OS = string | string[]
|
||||||
`build-os=${JSON.stringify(buildOs)}\n` +
|
|
||||||
`container=${JSON.stringify(container)}\n` +
|
|
||||||
`test-matrix=${JSON.stringify(testMatrix)}\n`
|
|
||||||
|
|
||||||
Deno.stdout.write(new TextEncoder().encode(output))
|
const platform = Deno.env.get("PLATFORM") ?? panic("$PLATFORM not set")
|
||||||
|
|
||||||
|
const cacheSets = {
|
||||||
|
"darwin": "$HOME/Library/Caches/deno/deps/https/",
|
||||||
|
"linux": "$HOME/.cache/deno/deps/https/"
|
||||||
|
}
|
||||||
|
|
||||||
|
const output: Output = (() => {
|
||||||
|
switch(platform) {
|
||||||
|
case "darwin+x86-64": {
|
||||||
|
// Using GHA resources for now, until we resolve network issues with our runners
|
||||||
|
// buildOs: ["self-hosted", "macOS", "X64"]
|
||||||
|
const os = "macos-11"
|
||||||
|
return {
|
||||||
|
os,
|
||||||
|
buildOs: os,
|
||||||
|
testMatrix: [{ os }],
|
||||||
|
cacheSet: cacheSets["darwin"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "darwin+aarch64": {
|
||||||
|
const os = ["self-hosted", "macOS", "ARM64"]
|
||||||
|
return {
|
||||||
|
os,
|
||||||
|
buildOs: os,
|
||||||
|
testMatrix: [{ os }],
|
||||||
|
cacheSet: cacheSets["darwin"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "linux+aarch64": {
|
||||||
|
const os = ["self-hosted", "linux", "ARM64"]
|
||||||
|
return {
|
||||||
|
os,
|
||||||
|
buildOs: os,
|
||||||
|
testMatrix: [{ os }],
|
||||||
|
cacheSet: cacheSets["linux"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "linux+x86-64": {
|
||||||
|
// Using GHA resources for now, until we resolve network issues with our runners
|
||||||
|
// buildOs: ["self-hosted", "linux", "X64"]
|
||||||
|
// testMatrix.push({ os: buildOs, container: undefined })
|
||||||
|
const os = "ubuntu-latest"
|
||||||
|
const container = "ghcr.io/teaxyz/infuser:latest"
|
||||||
|
return { os,
|
||||||
|
buildOs: os,
|
||||||
|
container,
|
||||||
|
testMatrix: [
|
||||||
|
{ os },
|
||||||
|
{ os, container },
|
||||||
|
{ os, container: "debian:buster-slim" }
|
||||||
|
],
|
||||||
|
cacheSet: cacheSets["linux"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
panic(`Invalid platform description: ${platform}`)
|
||||||
|
}})()
|
||||||
|
|
||||||
|
const rv = `os=${JSON.stringify(output.os)}\n` +
|
||||||
|
`build-os=${JSON.stringify(output.buildOs)}\n` +
|
||||||
|
`container=${JSON.stringify(output.container)}\n` +
|
||||||
|
`test-matrix=${JSON.stringify(output.testMatrix)}\n` +
|
||||||
|
`cache-set=${JSON.stringify(output.cacheSet)}\n`
|
||||||
|
|
||||||
|
Deno.stdout.write(new TextEncoder().encode(rv))
|
||||||
|
|
||||||
if (Deno.env.get("GITHUB_OUTPUT")) {
|
if (Deno.env.get("GITHUB_OUTPUT")) {
|
||||||
const envFile = Deno.env.get("GITHUB_OUTPUT")!
|
const envFile = Deno.env.get("GITHUB_OUTPUT")!
|
||||||
await Deno.writeTextFile(envFile, output, { append: true})
|
await Deno.writeTextFile(envFile, rv, { append: true})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue