Skip to content

Commit

Permalink
Merge pull request #524 from ducktors/remove-package-json-import
Browse files Browse the repository at this point in the history
fix: remove package.json import on status page
  • Loading branch information
matteovivona authored Feb 20, 2025
2 parents 25b8a8d + db254b2 commit ff703e7
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 28 deletions.
33 changes: 32 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ jobs:
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
name: Checkout
- name: Use Node.js
Expand All @@ -107,3 +106,35 @@ jobs:
run: pnpm lint
- name: Build
run: pnpm build

docker:
name: Test Docker Build
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0

- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: false
load: true
tags: turborepo-remote-cache:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Docker image
run: |
docker image ls
docker inspect turborepo-remote-cache:test


56 changes: 47 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:
types: [published]
workflow_dispatch:

permissions: read-all
permissions:
contents: read
packages: write

jobs:
docker-build:
name: Docker Build
docker-hub:
name: Docker Hub
runs-on: ubuntu-latest
steps:
- name: Harden Runner
Expand All @@ -36,7 +38,7 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
- name: Build and push to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
Expand All @@ -45,10 +47,46 @@ jobs:
push: true
tags: |
ducktors/turborepo-remote-cache:${{ steps.package-version.outputs.current-version}}
cache-from: |
type=gha
cache-to: |
type=gha,mode=max
cache-from: type=gha
cache-to: type=gha,mode=max

github-registry:
name: GitHub Container Registry
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get package version
id: package-version
uses: martinbeentjes/npm-get-version-action@3cf273023a0dda27efcd3164bdfb51908dd46a5b # main
with:
path: .
- name: Set up QEMU
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3.4.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to GitHub Registry
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}/turborepo-remote-cache:${{ steps.package-version.outputs.current-version}}
cache-from: type=gha
cache-to: type=gha,mode=max




3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit "$1"
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm test && pnpm build
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"homepage": "https://github.com/ducktors/turborepo-remote-cache#readme",
"engines": {
"node": ">=20.0.0",
"pnpm": ">=9.15.5"
"pnpm": ">=9.15.4"
},
"keywords": [
"turborepo",
Expand Down
12 changes: 1 addition & 11 deletions src/plugins/remote-cache/routes/get-status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { readFileSync } from 'fs'
import type { Server } from 'http'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
import type {
RawReplyDefaultExpression,
RawRequestDefaultExpression,
Expand All @@ -10,13 +7,6 @@ import type {
import { type Params, type Querystring } from './schema.js'
import { statusRouteSchema } from './status-schema.js'

// Get package.json version
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const packageJson = JSON.parse(
readFileSync(join(__dirname, '../../../../package.json'), 'utf8'),
)

export const getStatus: RouteOptions<
Server,
RawRequestDefaultExpression,
Expand All @@ -34,7 +24,7 @@ export const getStatus: RouteOptions<
async handler(req, reply) {
reply.send({
status: 'enabled',
version: packageJson.version,
version: process.env.npm_package_version ?? 'unknown',
})
},
}

0 comments on commit ff703e7

Please sign in to comment.