Skip to content

Commit

Permalink
Rewrite almost from scratch to update everything
Browse files Browse the repository at this point in the history
  • Loading branch information
trappar committed Feb 15, 2024
1 parent 15c6879 commit 6f8e474
Show file tree
Hide file tree
Showing 32 changed files with 7,234 additions and 8,596 deletions.
23 changes: 15 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{
"env": { "node": true },
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint"],
"env": {
"node": true,
"es2021": true
},
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"extends": ["eslint:recommended"],
"rules": {
"semi": ["error", "always"],
"quotes": ["error", "single"],
"indent": ["error", 2],
"comma-dangle": ["error", "always-multiline"]
},
"root": true
}
12 changes: 6 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ runs:
steps:
- uses: pnpm/action-setup@v2
with:
version: 7
version: 8
run_install: false

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-pnpm-store-

- run: pnpm install --prefer-offline
- run: pnpm install --prefer-offline --frozen-lockfile
shell: bash
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint
on: push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Run Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Check working copy
run: git diff --exit-code
62 changes: 48 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,64 @@ concurrency:
jobs:
test:
runs-on: ubuntu-latest
env:
TURBO_TELEMETRY_DISABLED: 1
steps:
- name: Checkout
uses: actions/checkout@v3

uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup

- name: Run Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Check working copy
run: git diff --exit-code

- name: Run TurboRepo Remote Cache Server
uses: ./
with:
storage-provider: local
storage-path: test
storage-path: turbo-cache

- name: Ensure environmental variables have been set correctly
run: |
echo $TURBO_API | grep -P "^http://127.0.0.1:\d+$"
echo $TURBO_API | grep -P "^http://0.0.0.0:\d+$"
echo $TURBO_TOKEN | grep -P "^[a-zA-Z0-9]{48}$"
echo $TURBO_TEAM | grep -P "^ci$"
echo $TURBO_TEAM | grep -P "^ci$"
- name: Run turbo:test with turbo and expect no cache
run: |
# Expect no cache entries
[ ! -d "/tmp/turbo-cache/ci" ] || exit 1
pnpm turbo turbo:test > /tmp/turbo-output
# Expect a single cache entry
[ $(find /tmp/turbo-cache/ci -type f | wc -l) -eq 1 ] || exit 1
- name: Rerun turbo:test with turbo and expect cache to be used
run: |
pnpm turbo turbo:test > /tmp/turbo-output
grep "Remote caching enabled" /tmp/turbo-output > /dev/null
grep "1 cached, 1 total" /tmp/turbo-output > /dev/null
grep "FULL TURBO" /tmp/turbo-output > /dev/null
# Expect there to still just be one cache entry stored
[ $(find /tmp/turbo-cache/ci -type f | wc -l) -eq 1 ] || exit 1
test-invalid-config:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Run TurboRepo Remote Cache Server with invalid storage provider
uses: ./
id: run-turbo
continue-on-error: true
with:
storage-provider: asdf
storage-path: asdf

- name: Error if prior step succeeded
if: steps.run-turbo.outcome == 'success'
run: exit 1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
log
log
.turbo
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

## Unreleased (will be V2)

### Changed
- Updated dependencies including turborepo-remote-cache
- Migrated from Typescript to Javascript (it just wasn't worth it)
- Updated action to run on node 20

### Fixed
- Updated `action.yml` to indicate that `storage-provider` and `storage-path` are required inputs. They were always required by the code.

## V1

### Added
- Initial release
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ A GitHub action which runs a [ducktors/turborepo-remote-cache](https://github.co

### `storage-path`

**Required** The name of the bucket to use. Supports all options from [environmental variables](https://ducktors.github.io/turborepo-remote-cache/environment-variables.html) for more information.
The name of the bucket/directory to use. Supports all options from [environmental variables](https://ducktors.github.io/turborepo-remote-cache/environment-variables.html) for more information.

### `team-id`

The Team ID to use. This controls the directory where cache entries will be saved. Default `"ci"`.

### `host`

Used to set the `TURBO_API` env variable. Default `"http://127.0.0.1"`.
Used to set the `TURBO_API` env variable. Default `"http://0.0.0.0"`.

### `port`

Expand All @@ -38,7 +38,7 @@ You may also need to set environment variables to provide credentials to the sto

```yaml
- name: TurboRepo Remote Cache Server
uses: trappar/turborepo-remote-cache-gh-action@main
uses: trappar/turborepo-remote-cache-gh-action@v2
with:
storage-provider: s3
storage-path: my-bucket-name
Expand Down
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ branding:
inputs:
storage-provider:
description: "Possible values are s3, google-cloud-storage, or azure-blob-storage. Local storage is technically supported but is useless."
required: false
required: true
storage-path:
description: "The name of s3, google-cloud-storage, or azure-blob-storage bucket."
required: false
required: true
team-id:
description: "Sets the TURBO_TEAM env variable, which controls the directory where cache entries will be saved."
required: false
default: "ci"
host:
description: "Used to set the TURBO_API env variable."
required: false
default: "http://127.0.0.1"
default: "http://0.0.0.0"
port:
description: "Sets the port the server will listen on, and is added to the end of the TURBO_API env variable."
required: false
runs:
using: "node16"
using: "node20"
main: "dist/start/index.js"
post: "dist/post/index.js"
Loading

0 comments on commit 6f8e474

Please sign in to comment.