Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate the native runner with a composite action #86

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

70 changes: 0 additions & 70 deletions .eslintrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

59 changes: 6 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: CI

on:
Expand All @@ -17,45 +12,12 @@ on:
workflow_dispatch:

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version-file: .nvmrc
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline

- name: Rebuild the dist/ directory
run: pnpm run build

- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/

test-action:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04", "ubuntu-22.04"]
runs-on: ${{ matrix.os }}
needs: check-dist
env:
CODSPEED_SKIP_UPLOAD: true
steps:
Expand All @@ -70,19 +32,10 @@ jobs:
working-directory: examples
# Check that the directory is actually changed
run: if [ $(basename $(pwd)) != "examples" ]; then exit 1; fi

tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
- name: Check action with multiline command
uses: ./
with:
cache: pnpm
node-version-file: .nvmrc
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline

- name: Run tests
run: pnpm test
run: |
echo "Working";
echo "with";
echo "multiple lines";
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

<sub>
The format is based on <a href="https://keepachangelog.com/en/1.0.0/">Keep a Changelog</a>,
and this project adheres to <a href="https://semver.org/spec/v2.0.0.html">Semantic Versioning</a>.
</sub>

## [Unreleased]

### Breaking changes

- `upload_url` input is now `upload-url`
- `pytest-codspeed` is no longer installed automatically by this action
44 changes: 40 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,51 @@ inputs:
run:
description: "The command to run the benchmarks"
required: true

working-directory:
description: |
The directory where the `run` command will be executed.
Warning: if you use defaults.working-directory, you must still set this parameter.
required: false
upload_url:
upload-url:
description: "The upload endpoint (for on-premise deployments)"
default: "https://api.codspeed.io/upload"
required: false

runner-version:
description: "The version of the runner to use"
default: "2.0.0"
required: true

runs:
using: "node16"
main: "dist/index.js"
using: "composite"
steps:
# Build the args string
- id: args
shell: bash
run: |
args=""
if [ -n "${{ inputs.token }}" ]; then
args="$args --token ${{ inputs.token }}"
fi
if [ -n "${{ inputs.working-directory }}" ]; then
args="$args --working-directory=${{ inputs.working-directory }}"
fi
if [ -n "${{ inputs.upload-url }}" ]; then
args="$args --upload-url=${{ inputs.upload-url }}"
fi
echo "args=$args" >> $GITHUB_OUTPUT

# Install the CodSpeedHQ/runner
- shell: bash
run: |
head_status=$(curl -I -fsSL -w "%{http_code}" -o /dev/null https://github.com/CodSpeedHQ/runner/releases/download/v${{ inputs.runner-version }}/codspeed-runner-installer.sh)
if [ "$head_status" -eq 404 ]; then
echo "Error: Version ${{ inputs.runner-version }} is not available in https://github.com/CodSpeedHQ/runner/releases, please a correct version."
exit 1
else
curl -fsSL https://github.com/CodSpeedHQ/runner/releases/download/v${{ inputs.runner-version }}/codspeed-runner-installer.sh | bash
fi

# Run the benchmarks
- shell: bash
run: codspeed-runner ${{ steps.args.outputs.args }} -- '${{ inputs.run }}'
50 changes: 0 additions & 50 deletions dist/bin/node

This file was deleted.

Loading