diff --git a/.dev/README.md b/.dev/README.md new file mode 100644 index 0000000..26baa75 --- /dev/null +++ b/.dev/README.md @@ -0,0 +1,2 @@ + +This directory is used for local testing. Nothing to see here. \ No newline at end of file diff --git a/.dev/test-env.js b/.dev/test-env.js new file mode 100644 index 0000000..2eab546 --- /dev/null +++ b/.dev/test-env.js @@ -0,0 +1,16 @@ +const path = require('path') + +if (!process.env.RUNNER_TEMP) { + process.env.RUNNER_TOOL_CACHE = path.resolve( + __dirname, + 'tool-cache' + ) + process.env.RUNNER_TEMP = path.resolve( + __dirname, + 'tmp' + ) + process.env.ELIDE_HOME = path.resolve( + __dirname, + 'target' + ) +} diff --git a/.eslintignore b/.eslintignore index 9ff5c1c..193716c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,5 @@ lib/ dist/ node_modules/ coverage/ +__tests__/ +.dev/ diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a9802d7..68cc0d2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1 @@ -# Repository CODEOWNERS - -* @actions/actions-runtime -* @ncalteen +* @sgammon diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..09f80b7 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at benasher44@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..8788565 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,4 @@ + +## Security Policy + +Please report all security issues to our [central project](https://github.com/elide-dev/elide). Also, see our [Security Policy](https://github.com/elide-dev/elide/security/policy) which is hosted in that repo. diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..b8044dd --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,14 @@ +codecov: + require_ci_to_pass: true + +ignore: + - "__tests__" + - "dist" + - "node_modules" + +comment: # this is a top-level key + layout: "diff, flags, files" + behavior: default + require_changes: false + require_base: false + require_head: true diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 444f1a9..661f84d 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,48 +1,51 @@ -# In TypeScript actions, `dist/index.js` is a special file. When you reference -# an action with `uses:`, `dist/index.js` is the code that will be run. For this -# project, the `dist/index.js` file is generated from other source files through -# the build process. We need to make sure that the checked-in `dist/index.js` -# file matches what is expected from the build. -# -# This workflow will fail if the checked-in `dist/index.js` file does not match -# what is expected from the build. -name: Check dist/ +name: Check Dist on: - push: - branches: - - main - pull_request: - workflow_dispatch: + workflow_dispatch: {} + workflow_call: {} permissions: contents: read jobs: check-dist: - name: Check dist/ + name: "Check: Dist" runs-on: ubuntu-latest + permissions: + contents: read + statuses: write + steps: - - name: Checkout + - name: Harden Runner + uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 + with: + egress-policy: audit + + - name: "Setup: Checkout" id: checkout - uses: actions/checkout@v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + + - name: "Setup: PNPM" + uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0 + with: + version: 8.9.0 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: "Setup: Node" + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 with: - node-version-file: .node-version - cache: npm + node-version: 20 + cache: pnpm - - name: Install Dependencies + - name: "Setup: Install Dependencies" id: install - run: npm ci + run: pnpm install && pnpm install -g turbo - - name: Build dist/ Directory + - name: "Build: Bundle" id: build - run: npm run bundle + run: turbo build --token ${{ secrets.BUILDLESS_APIKEY }} --no-daemon --remote-only - - name: Compare Expected and Actual Directories + - name: "Check: Compare Expected and Actual Directories" id: diff run: | if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then @@ -51,9 +54,8 @@ jobs: exit 1 fi - # If index.js was different than expected, upload the expected version as - # a workflow artifact. - - uses: actions/upload-artifact@v3 + - name: "Build: Upload Artifact" + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 if: ${{ failure() && steps.diff.conclusion == 'failure' }} with: name: dist diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dfab1c..91e4f0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,63 +1,105 @@ -name: Continuous Integration +name: CI on: - pull_request: + pull_request: {} + merge_group: {} push: branches: - main - 'releases/*' -permissions: - contents: read - jobs: test-typescript: - name: TypeScript Tests + name: "Test: Unit Tests" runs-on: ubuntu-latest steps: - - name: Checkout + - name: Harden Runner + uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 + with: + egress-policy: audit + + - name: "Setup: Checkout" id: checkout - uses: actions/checkout@v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - name: Setup Node.js - id: setup-node - uses: actions/setup-node@v4 + - name: "Setup: PNPM" + uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0 with: - node-version-file: .node-version - cache: npm + version: 8.9.0 - - name: Install Dependencies - id: npm-ci - run: npm ci + - name: "Setup: Node" + id: setup-node + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 + with: + node-version: 20 + cache: pnpm + - name: "Setup: Install Dependencies" + id: install + run: pnpm install && pnpm install -g turbo + - name: Check Format id: npm-format-check - run: npm run format:check + run: pnpm run format:check - name: Lint id: npm-lint - run: npm run lint + run: pnpm run lint - name: Test id: npm-ci-test - run: npm run ci-test + run: turbo test --token ${{ secrets.BUILDLESS_APIKEY }} --no-daemon --remote-only + + - name: "Test: Sonar" + uses: SonarSource/sonarcloud-github-action@5ee47de3c96f0c1c51b09d2ff1fec0cfeefcf67c # master + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dsonar.organization=buildless + -Dsonar.projectKey=buildless_setup-buildless + -Dsonar.python.coverage.reportPaths=coverage.xml + -Dsonar.sources=src/ + -Dsonar.tests=__tests__/ + -Dsonar.verbose=true + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + -Dsonar.testExecutionReportPaths=test-report.xml + + - name: "Report: Coverage" + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} test-action: - name: GitHub Actions Test + name: "Test: Actions" runs-on: ubuntu-latest steps: - - name: Checkout + - name: Harden Runner + uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 + with: + egress-policy: audit + + - name: "Setup: Checkout" id: checkout - uses: actions/checkout@v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - name: Test Local Action + - name: "Test: Local Action" id: test-action uses: ./ - with: - milliseconds: 1000 + with: {} - - name: Print Output + - name: "Test: Print Output" id: output - run: echo "${{ steps.test-action.outputs.time }}" + run: echo "${{ steps.test-action.outputs.path }}" + + check-dist: + name: "Test: Dist" + uses: ./.github/workflows/check-dist.yml + secrets: inherit + permissions: + contents: read + statuses: write diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index bcaf277..1ea8057 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -10,10 +10,14 @@ on: schedule: - cron: '31 7 * * 3' +permissions: + contents: read + jobs: analyze: name: Analyze runs-on: ubuntu-latest + continue-on-error: true permissions: actions: read @@ -28,21 +32,28 @@ jobs: - TypeScript steps: + - name: Harden Runner + uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 + with: + egress-policy: audit + - name: Checkout id: checkout - uses: actions/checkout@v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - name: Initialize CodeQL id: initialize - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3 with: languages: ${{ matrix.language }} source-root: src - name: Autobuild id: autobuild - uses: github/codeql-action/autobuild@v2 + continue-on-error: true + uses: github/codeql-action/autobuild@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3 - name: Perform CodeQL Analysis id: analyze - uses: github/codeql-action/analyze@v2 + continue-on-error: true + uses: github/codeql-action/analyze@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..9c697a4 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,27 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, +# surfacing known-vulnerable versions of the packages declared or updated in the PR. +# Once installed, if the workflow run is marked as required, +# PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +name: 'Dependency Review' +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 + with: + egress-policy: audit + + - name: 'Checkout Repository' + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - name: 'Dependency Review' + uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1 diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 1f1c52c..0c1f5a9 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,41 +1,55 @@ -name: Lint Code Base +name: Lint on: pull_request: branches: - main push: - branches: + branches-ignore: - main permissions: contents: read - statuses: write jobs: lint: - name: Lint Code Base + name: "Check: Lint" runs-on: ubuntu-latest + permissions: + contents: read + packages: read + statuses: write + steps: - - name: Checkout + - name: Harden Runner + uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 + with: + egress-policy: audit + + - name: "Setup: Checkout" id: checkout - uses: actions/checkout@v4 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - name: Setup Node.js + - name: "Setup: PNPM" + uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0 + with: + version: 8.9.0 + + - name: "Setup: Node" id: setup-node - uses: actions/setup-node@v4 + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 with: - node-version-file: .node-version - cache: npm + node-version: 20 + cache: pnpm - - name: Install Dependencies + - name: "Setup: Install Dependencies" id: install - run: npm ci - + run: pnpm install + - name: Lint Code Base id: super-linter - uses: super-linter/super-linter/slim@v5 + uses: super-linter/super-linter/slim@3213b9ea991e2d45d760ea8a76aaebad8a2bdb1a # v5.4.0 env: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 0000000..da2f9a5 --- /dev/null +++ b/.github/workflows/scorecards.yml @@ -0,0 +1,76 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '20 7 * * 2' + push: + branches: ["main"] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + contents: read + actions: read + + steps: + - name: Harden Runner + uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 + with: + egress-policy: audit + + - name: "Checkout code" + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecards on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Upload artifact" + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@0116bc2df50751f9724a2e35ef1f24d22f90e4e1 # v2.22.3 + with: + sarif_file: results.sarif diff --git a/.gitignore b/.gitignore index 47fb503..5abece2 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,19 @@ __tests__/runner/* .idea .vscode *.code-workspace + +# Turbo Build +.turbo/cache +.turbo-cookie + +# Local codebase stuff +.dev/codebase + +# Local testing scratch space +.dev/tmp/* +!.dev/tmp/.gitkeep +.dev/tool-cache/* +!.dev/tool-cache/.gitkeep +.dev/target/* +!.dev/target/.gitkeep +test-report.xml diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100644 index 0000000..c160a77 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx --no -- commitlint --edit ${1} diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..4d5183f --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +registry=https://npm.pkg.st/ +timeout=30000 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..723e338 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: https://github.com/gitleaks/gitleaks + rev: v8.16.3 + hooks: + - id: gitleaks +- repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shellcheck +- repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.38.0 + hooks: + - id: eslint +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index a378146..0000000 --- a/.prettierrc.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "printWidth": 80, - "tabWidth": 2, - "useTabs": false, - "semi": false, - "singleQuote": true, - "quoteProps": "as-needed", - "jsxSingleQuote": false, - "trailingComma": "none", - "bracketSpacing": true, - "bracketSameLine": true, - "arrowParens": "avoid", - "proseWrap": "always", - "htmlWhitespaceSensitivity": "css", - "endOfLine": "lf" -} diff --git a/.turbo/config.json b/.turbo/config.json new file mode 100644 index 0000000..b3d5b81 --- /dev/null +++ b/.turbo/config.json @@ -0,0 +1,6 @@ +{ + "apiurl": "https://turbo.less.build", + "loginurl": "https://beta.less.build", + "teamslug": null, + "teamid": "waad|XZn2X9N9Fws_B8jWPv3jeczmxpS_BHMjLxT3jQFI6PQ" +} \ No newline at end of file diff --git a/README.md b/README.md index ebe33cc..0c59f5d 100644 --- a/README.md +++ b/README.md @@ -1,224 +1,83 @@ -# Create a GitHub Action Using TypeScript -[![GitHub Super-Linter](https://github.com/actions/typescript-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter) -![CI](https://github.com/actions/typescript-action/actions/workflows/ci.yml/badge.svg) -[![Check dist/](https://github.com/actions/typescript-action/actions/workflows/check-dist.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/check-dist.yml) -[![CodeQL](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml) -[![Coverage](./badges/coverage.svg)](./badges/coverage.svg) +# GitHub Action: Setup Buildless -Use this template to bootstrap the creation of a TypeScript action. :rocket: +This repository provides a [GitHub Action][0] to setup [Buildless][1] within your workflows. Supported features: -This template includes compilation support, tests, a validation workflow, -publishing, and versioning guidance. +- **Buildless CLI:** Install and authorize the Buildless CLI +- **Buildless Agent:** Install and run the near-caching Buildless Agent +- **GHA-compatible:** Drop-in replacement for `actions/cache` (it's just faster, and linked to your Buildless account) -If you are new, there's also a simpler introduction in the -[Hello world JavaScript action repository](https://github.com/actions/hello-world-javascript-action). - -## Create Your Own Action - -To create your own action, you can use this repository as a template! Just -follow the below instructions: - -1. Click the **Use this template** button at the top of the repository -1. Select **Create a new repository** -1. Select an owner and name for your new repository -1. Click **Create repository** -1. Clone your new repository - -## Initial Setup - -After you've cloned the repository to your local machine or codespace, you'll -need to perform some initial setup steps before you can develop your action. - -> [!NOTE] -> -> You'll need to have a reasonably modern version of -> [Node.js](https://nodejs.org) handy (20.x or later should work!). If you are -> using a version manager like [`nodenv`](https://github.com/nodenv/nodenv) or -> [`nvm`](https://github.com/nvm-sh/nvm), this template has a `.node-version` -> file at the root of the repository that will be used to automatically switch -> to the correct version when you `cd` into the repository. Additionally, this -> `.node-version` file is used by GitHub Actions in any `actions/setup-node` -> actions. - -1. :hammer_and_wrench: Install the dependencies - - ```bash - npm install - ``` - -1. :building_construction: Package the TypeScript for distribution - - ```bash - npm run bundle - ``` - -1. :white_check_mark: Run the tests - - ```bash - $ npm test - - PASS ./index.test.js - ✓ throws invalid number (3ms) - ✓ wait 500 ms (504ms) - ✓ test runs (95ms) - - ... - ``` - -## Update the Action Metadata - -The [`action.yml`](action.yml) file defines metadata about your action, such as -input(s) and output(s). For details about this file, see -[Metadata syntax for GitHub Actions](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions). - -When you copy this repository, update `action.yml` with the name, description, -inputs, and outputs for your action. - -## Update the Action Code - -The [`src/`](./src/) directory is the heart of your action! This contains the -source code that will be run when your action is invoked. You can replace the -contents of this directory with your own code. - -There are a few things to keep in mind when writing your action code: - -- Most GitHub Actions toolkit and CI/CD operations are processed asynchronously. - In `main.ts`, you will see that the action is run in an `async` function. - - ```javascript - import * as core from '@actions/core' - //... - - async function run() { - try { - //... - } catch (error) { - core.setFailed(error.message) - } - } - ``` - - For more information about the GitHub Actions toolkit, see the - [documentation](https://github.com/actions/toolkit/blob/master/README.md). - -So, what are you waiting for? Go ahead and start customizing your action! - -1. Create a new branch - - ```bash - git checkout -b releases/v1 - ``` - -1. Replace the contents of `src/` with your action code -1. Add tests to `__tests__/` for your source code -1. Format, test, and build the action - - ```bash - npm run all - ``` +## Usage - > [!WARNING] - > - > This step is important! It will run [`ncc`](https://github.com/vercel/ncc) - > to build the final JavaScript action code with all dependencies included. - > If you do not run this step, your action will not work correctly when it is - > used in a workflow. This step also includes the `--license` option for - > `ncc`, which will create a license file for all of the production node - > modules used in your project. +**Install the latest Buildless CLI, add it to the `PATH`, and run the agent** +```yaml + - name: "Setup: Buildless" + uses: buildless/setup-buildless@v1 +``` -1. Commit your changes +**Install the latest Buildless CLI, add it to the `PATH`, without the agent:** +```yaml + - name: "Setup: Buildless" + uses: buildless/setup-buildless@v1 + with: + agent: false # you really should use the agent tho +``` - ```bash - git add . - git commit -m "My first action is ready!" - ``` +## Authorization -1. Push them to your repository +The CLI and Agent will both **automatically use `BUILDLESS_APIKEY`**, if present, to authorize cache traffic and cloud backhaul. +If no authorization material is present, only local caching is enabled. - ```bash - git push -u origin releases/v1 - ``` +Sign up for a [Buildless Cloud][1] account to obtain an API key. It's free to start. -1. Create a pull request and get feedback on your action -1. Merge the pull request into the `main` branch +## Options -Your action is now published! :rocket: +The full suite of available options are below. -For information about versioning your action, see -[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) -in the GitHub Actions toolkit. +| Option | Type | Default | Description | +| ------------- | ------------ | ----------------------------------------------------------- | -------------------------------------------- | +| `version` | `string` | `latest` | Version to install; defaults to `latest` | +| `os` | `string` | (Current) | OS to target; defaults to current platform | +| `arch` | `string` | (Current) | Arch to target; defaults to current platform | +| `agent` | `boolean` | `true` | Install and start the Buildless Agent | +| `apikey` | `string` | `${{ env.BUILDLESS_API_KEY || secrets.BUILDLESS_API_KEY }}` | Perform a self-test after installing | +| `token` | `string` | `${{ env.GITHUB_TOKEN }}` | GitHub token to use for fetching assets | +| `export_path` | `boolean` | `true` | Whether to install Buildless onto the `PATH` | -## Validate the Action +**Options for `os`** (support varies) +- `darwin`, `mac`, `macos` +- `windows`, `win32` +- `linux` -You can now validate the action by referencing it in a workflow file. For -example, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference an -action in the same repository. +**Options for `arch`** (support varies) +- `amd64`, `x64`, `x86_64` +- `arm64`, `aarch64` +**Full configuration sample with defaults** ```yaml -steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - - - name: Test Local Action - id: test-action - uses: ./ + - name: "Setup: Buildless" + uses: buildless/setup-buildless@v1 with: - milliseconds: 1000 - - - name: Print Output - id: output - run: echo "${{ steps.test-action.outputs.time }}" + version: latest + os: linux + arch: amd64 + agent: true + apikey: ${{ env.BUILDLESS_API_KEY || secrets.BUILDLESS_API_KEY }} + token: ${{ env.GITHUB_TOKEN }} + export_path: true ``` -For example workflow runs, check out the -[Actions tab](https://github.com/actions/typescript-action/actions)! :rocket: - -## Usage +## What is Buildless? -After testing, you can create version tag(s) that developers can use to -reference different stable versions of your action. For more information, see -[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) -in the GitHub Actions toolkit. +[Buildless][0] is a build caching system which works with most build tools. If you have a build tool that supports remote caching, Buildless can +probably plug right in, and it makes development fast and fun. -To include the action in a workflow in another repository, you can use the -`uses` syntax with the `@` symbol to reference a specific branch, tag, or commit -hash. +Supported language ecosystems and toolchains include: -```yaml -steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - - - name: Test Local Action - id: test-action - uses: actions/typescript-action@v1 # Commit with the `v1` tag - with: - milliseconds: 1000 - - - name: Print Output - id: output - run: echo "${{ steps.test-action.outputs.time }}" -``` +- **Gradle, Maven, JVM** (Kotlin, Java, Groovy, Scala, et al) +- **Bazel** (supports gRPC build cache APIs) +- **C, C++, Swift, Rust, etc** (C-like toolchains, via tools like `sccache`) +- **JavaScript, TypeScript, CSS, etc** (with tools like `turborepo`) -## Publishing a new release - -This project includes a helper script designed to streamline the process of -tagging and pushing new releases for GitHub Actions. - -GitHub Actions allows users to select a specific version of the action to use, -based on release tags. Our script simplifies this process by performing the -following steps: - -1. **Retrieving the latest release tag:** The script starts by fetching the most - recent release tag by looking at the local data available in your repository. -1. **Prompting for a new release tag:** The user is then prompted to enter a new - release tag. To assist with this, the script displays the latest release tag - and provides a regular expression to validate the format of the new tag. -1. **Tagging the new release:** Once a valid new tag is entered, the script tags - the new release. -1. **Pushing the new tag to the remote:** Finally, the script pushes the new tag - to the remote repository. From here, you will need to create a new release in - GitHub and users can easily reference the new tag in their workflows. +[0]: https://github.com/features/actions +[1]: https://less.build diff --git a/action.yml b/action.yml index 101186a..0b650b1 100644 --- a/action.yml +++ b/action.yml @@ -1,20 +1,55 @@ -name: 'The name of your action here' -description: 'Provide a description here' -author: 'Your name or organization here' +name: 'Setup Buildless' +description: 'Lightning-fast build caching for Github Actions with Buildless' +author: 'Buildless' -# Add your action's branding here. This will appear on the GitHub Marketplace. branding: - icon: 'heart' - color: 'red' + icon: box + color: purple -# Define your inputs here. inputs: - milliseconds: - description: 'Your input description here' - required: true - default: '1000' + version: + description: 'Version' + required: false + default: 'latest' + + os: + description: 'OS' + required: false + + arch: + description: 'Architecture' + required: false + + target: + description: 'Custom install path' + required: false + + force: + description: 'Force install' + required: false + + export_path: + description: 'Export to Path' + required: false + default: 'true' + + custom_url: + description: 'Custom Download URL' + required: false + + token: + description: 'GitHub Token' + required: false + + agent: + description: 'Enable Buildless Agent' + required: false + default: 'true' + + apikey: + description: 'Buildless API key' + required: false -# Define your outputs here. outputs: time: description: 'Your output description here' diff --git a/package.json b/package.json index 5e73940..80c44a9 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,16 @@ { "name": "typescript-action", - "description": "GitHub Actions TypeScript template", - "version": "0.0.0", - "author": "", + "description": "Github Action to setup caching with Buildless", + "version": "1.0.0", + "author": "Buildless (https://less.build)", "private": true, - "homepage": "https://github.com/actions/typescript-action", + "homepage": "https://github.com/buildless/setup-buildless", "repository": { "type": "git", - "url": "git+https://github.com/actions/typescript-action.git" + "url": "git+https://github.com/buildless/setup-buildless.git" }, "bugs": { - "url": "https://github.com/actions/typescript-action/issues" + "url": "https://github.com/buildless/setup-buildless/issues" }, "keywords": [ "actions", @@ -36,11 +36,24 @@ "all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package" }, "license": "MIT", + "jestSonar": {}, "jest": { "preset": "ts-jest", "verbose": true, "clearMocks": true, "testEnvironment": "node", + "testResultsProcessor": "jest-sonar-reporter", + "setupFiles": [ + "/.dev/test-env.js" + ], + "coverageThreshold": { + "global": { + "branches": 20, + "functions": 20, + "lines": 40, + "statements": 20 + } + }, "moduleFileExtensions": [ "js", "ts" @@ -85,5 +98,33 @@ "prettier-eslint": "^16.1.2", "ts-jest": "^29.1.1", "typescript": "^5.3.2" + }, + "commitlint": { + "extends": [ + "@commitlint/config-conventional" + ], + "rules": { + "signed-off-by": [ + 2, + "always", + "Signed-off-by:" + ] + } + }, + "prettier": { + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": false, + "singleQuote": true, + "quoteProps": "as-needed", + "jsxSingleQuote": false, + "trailingComma": "none", + "bracketSpacing": true, + "bracketSameLine": true, + "arrowParens": "avoid", + "proseWrap": "always", + "htmlWhitespaceSensitivity": "css", + "endOfLine": "lf" } } diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..e6d23a5 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,7 @@ +// Version of the GitHub API to use. +export const GITHUB_API_VERSION = '2022-11-28' + +// Default headers to send on GitHub API requests. +export const GITHUB_DEFAULT_HEADERS = { + 'X-GitHub-Api-Version': GITHUB_API_VERSION +} diff --git a/tsconfig.json b/tsconfig.json index 2f26aac..1f67ef3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "target": "ES2022", - "module": "NodeNext", + "target": "esnext", + "module": "nodenext", "rootDir": "./src", - "moduleResolution": "NodeNext", + "moduleResolution": "nodenext", "baseUrl": "./", "sourceMap": true, "outDir": "./dist", diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..fc3c8e7 --- /dev/null +++ b/turbo.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": {}, + "test": {} + }, + "globalDependencies": [ + ".env", + "tsconfig.json" + ] +} \ No newline at end of file