Skip to content

Commit

Permalink
Create v2 (#94)
Browse files Browse the repository at this point in the history
* reset

* test

* npm run build

* create test

* debug

* actually run action

* provide fetch

* handle actions paths properly

* debug

* debug

* rm debugging

* update actions test

* tweak test

* github api requests with runner token

* vega option

* typo

* remove manual test

* link to v1 tree
  • Loading branch information
dacbd authored Sep 28, 2023
1 parent 0424d86 commit f714cd2
Show file tree
Hide file tree
Showing 17 changed files with 22,677 additions and 11,604 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*

!src/
53 changes: 31 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true
},
extends: [
'standard',
'prettier'
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018
},
ignorePatterns: ['assets/', 'dist/', 'node_modules/'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
rules: {
'camelcase': [1, {'properties': 'never'}],
'prettier/prettier': 'error'
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}],
'node/no-extraneous-import': 'error'
},
plugins: [
'prettier'
],
env: {
jest: true
node: true,
es6: true,
'jest/globals': true
}
}
};
59 changes: 30 additions & 29 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ jobs:
- uses: actions/checkout@v3
- run: |
npm ci
npm run format
npm run lint
npm run build
git diff --exit-code
check:
test-latest:
defaults:
run:
shell: bash
Expand All @@ -31,38 +33,37 @@ jobs:
runs-on: ${{ matrix.system }}
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run lint
- run: npm run test

- name: local action with '0.14.0'
uses: ./
with:
version: '0.14.0'

- name: test CML specific version
if: matrix.system != 'windows-latest'
run: |
if [ "$(cml --version 2>&1)" != '0.14.0' ]; then
exit 1
fi
echo OK
- name: local action with defaults
- name: run action with latest
uses: ./

- name: test CML latest version
if: matrix.system != 'windows-latest'
run: |
if [ "$(cml --version 2>&1)" == '0.14.0' ]; then
exit 1
fi
echo OK
- name: test
run: cml --version
- name: test CML
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo 'Hello CML from ${{ matrix.system }}!' > report.md
cml comment create ${{ github.event_name == 'pull_request' && '--target=pr' }} report.md
cml comment create report.md
cml check create report.md
test-version:
defaults:
run:
shell: bash
strategy:
matrix:
system:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.system }}
steps:
- uses: actions/checkout@v3
- name: run action with latest
uses: ./
with:
version: v0.15.1
- name: test CML specific version
run: |
if [ "$(cml --version 2>&1)" != '0.15.1' ]; then
exit 1
fi
echo OK
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*

!.github/
!src/
10 changes: 10 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};
6 changes: 0 additions & 6 deletions .restyled.yaml

This file was deleted.

33 changes: 12 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ This action gives you:
Note that CML does not include DVC and its dependencies (see the
[Setup DVC Action](https://github.com/iterative/setup-dvc)).

## Note on v2

`v1` of setup-cml was a wrapper around a set of npm installs. `v2` installs CML from its
pre-packaged binaries. Then attempts to run `npm install --global canvas@2 vega@5 vega-cli@5 vega-lite@5`
if you do not wish to install these tools pass `vega: false` to the action.

link to [`v1`](https://github.com/iterative/setup-cml/tree/v1)
## Usage

This action is tested on `ubuntu-latest`, `macos-latest` and `windows-latest`.
Expand All @@ -36,44 +43,28 @@ Basic usage:
```yaml
steps:
- uses: actions/checkout@v3
- uses: iterative/setup-cml@v1
- uses: iterative/setup-cml@v2
```
A specific version can be pinned to your workflow.
```yaml
steps:
- uses: actions/checkout@v3
- uses: iterative/setup-cml@v1
- uses: iterative/setup-cml@v2
with:
version: '0.18.1'
```
Self-hosted example:
```yaml
runs-on: [self-hosted]
steps:
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: actions/checkout@v3
- uses: iterative/setup-cml@v1
with:
sudo: false
```
## Inputs
The following inputs are supported.
- `version` - (optional) The version of CML to install (e.g. '0.18.1'). Defaults
to `latest` for the
[most recent CML release](https://github.com/iterative/cml/releases).
- `sudo` - (optional) Enables the use of sudo whilst installing CML. Defaults to
`true`
- `force` - (optional) Forces the install. Useful in scenarios where CML is
already installed and in use. Defaults to `false`
- `vega` - (optional) Whether to install vega dependencies. Defaults to `true`.
runs command `npm install --global canvas@2 vega@5 vega-cli@5 vega-lite@5`

## A complete example

Expand All @@ -86,7 +77,7 @@ Assume that we have a machine learning script, `train.py` which outputs an image
```yaml
steps:
- uses: actions/checkout@v2
- uses: iterative/setup-cml@v1
- uses: iterative/setup-cml@v2
- env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Can use the default token for most functions
run: |
Expand Down
10 changes: 3 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ inputs:
description: The version of CML to install (e.g. '3.0.0').
default: latest
required: false
sudo:
description: A flag to disable the use of sudo whilst installing CML.
default: true
required: false
force:
description: Force install CML if it exists.
default: false
vega:
description: Whether to install Vega tools
default: 'true'
required: false
runs:
using: node16
Expand Down
Loading

0 comments on commit f714cd2

Please sign in to comment.