14 Commits

Author SHA1 Message Date
Oscar Dowson
03114f09f1 Fix when input directories are not found (#20)
* Fix when input directories are not found

* Update main.jl

Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com>

Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com>
2022-12-21 20:01:07 -05:00
Fredrik Ekre
605cc6b85a RFC: change default directory to src,ext. (#19) 2022-12-21 23:56:53 +01:00
Curtis Vogt
6e018a9646 Use codecov-action@v2 in examples (#11) 2021-10-26 16:35:58 +02:00
Jim Garrison
a89a6dbd45 Update README link to PkgTemplates.jl (#10)
The target file was renamed in https://github.com/invenia/PkgTemplates.jl/pull/252
2021-10-01 10:08:13 +02:00
Eric Hanson
52227d0278 Add directories input (#8)
Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
Co-authored-by: Michael Schlottke-Lakemper <michael@sloede.com>
2021-06-05 12:04:57 +02:00
Sascha Mann
f555f2b0e5 Add automated backup workflow (#7) 2020-12-19 14:45:37 +01:00
Sascha Mann
40c067cf87 Make the @julia-actions/reviewers the global code owners for this repo 2020-12-14 14:35:01 +01:00
Amin Yahyaabadi
6cb1ebb8b8 Add README (#5) 2020-08-14 15:02:09 +02:00
Sascha Mann
033f480817 Update action.yml 2020-08-10 11:09:09 +02:00
Sascha Mann
56e1b4a2ad Add branding 2020-08-10 11:09:09 +02:00
Sascha Mann
8770d860a9 Change to composite action 2020-08-10 11:09:09 +02:00
Sascha Mann
d2bbf07e54 Undelete main.jl 2020-08-10 11:09:09 +02:00
Sascha Mann
9d5ffc5655 Bump year and add author in LICENCE 2020-08-10 11:09:09 +02:00
Sascha Mann
c9fce93b2a Remove everything 2020-08-10 11:09:09 +02:00
20 changed files with 99 additions and 8509 deletions

View File

@@ -1,3 +0,0 @@
dist/
lib/
node_modules/

View File

@@ -1,58 +0,0 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/es6"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-object-literal-type-assertion": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-interface": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}

1
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1 @@
* @julia-actions/reviewers

33
.github/workflows/backup.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Backup
on:
schedule:
- cron: '5 4 * * 0'
workflow_dispatch:
jobs:
backup:
runs-on: ubuntu-20.04
steps:
- name: Configure cache
uses: actions/cache@v2
with:
path: |
${{ env.GITHUB_WORKSPACE }}
~/.cache/restic
key: ${{ runner.os }}
- name: Install the correct Python version
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Run backup action
uses: julia-actions/restic-action@main
env: # Options: https://restic.readthedocs.io/en/latest/040_backup.html#environment-variables
RESTIC_REPOSITORY: b2:${{ secrets.B2_BUCKET }}:${{ github.repository }}
RESTIC_PASSWORD: ${{ secrets.RESTIC_PASSWORD }}
B2_ACCOUNT_ID: ${{ secrets.B2_ACCOUNT_ID }}
B2_ACCOUNT_KEY: ${{ secrets.B2_ACCOUNT_KEY }}

View File

@@ -1,23 +0,0 @@
name: "build-test"
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- master
- 'releases/*'
jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: |
npm install
npm run all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
milliseconds: 1000

99
.gitignore vendored
View File

@@ -1,99 +0,0 @@
# Dependency directory
node_modules
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# OS metadata
.DS_Store
Thumbs.db
# Ignore built ts files
__tests__/runner/*
lib/**/*

View File

@@ -1,3 +0,0 @@
dist/
lib/
node_modules/

View File

@@ -1,11 +0,0 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}

View File

@@ -1,7 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2018 GitHub, Inc. and contributors Copyright (c) 2018-2020 GitHub, Inc., David Anthoff and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

117
README.md
View File

@@ -2,100 +2,35 @@
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a> <a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
</p> </p>
# Create a JavaScript Action using TypeScript ## Usage
Use this template to bootstrap the creation of a JavaScript action.:rocket: See [PkgTemplates.jl](https://github.com/invenia/PkgTemplates.jl/blob/master/test/fixtures/AllPlugins/.github/workflows/CI.yml) for a complete example.
This template includes compilication support, tests, a validation workflow, publishing, and versioning guidance.
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
## Create an action from this template
Click the `Use this Template` and provide the new repo details for your action
## Code in Master
Install the dependencies
```bash
$ npm install
```
Build the typescript and package it for distribution
```bash
$ npm run build && npm run pack
```
Run the tests :heavy_check_mark:
```bash
$ npm test
PASS ./index.test.js
✓ throws invalid number (3ms)
wait 500 ms (504ms)
test runs (95ms)
...
```
## Change action.yml
The action.yml contains defines the inputs and output for your action.
Update the action.yml with your name, description, inputs and outputs for your action.
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
## Change the Code
Most toolkit and CI/CD operations involve async operations so 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);
}
}
run()
```
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
## Publish to a distribution branch
Actions are run from GitHub repos so we will checkin the packed dist folder.
Then run [ncc](https://github.com/zeit/ncc) and push the results:
```bash
$ npm run pack
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1
```
Your action is now published! :rocket:
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
## Validate
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)])
```yaml ```yaml
uses: ./
with: - uses: julia-actions/julia-processcoverage@v1
milliseconds: 1000 - uses: codecov/codecov-action@v2
with:
files: lcov.info
``` ```
See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket: One can also specify the directory or directories (comma separated) to use via the `directories` input (which defaults to `src,ext`). E.g.
```yaml
## Usage: - uses: julia-actions/julia-processcoverage@v1
with:
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action directories: src,ext,examples
- uses: codecov/codecov-action@v2
with:
files: lcov.info
```
instructs the action to look for coverage information in `src`, `ext`, and an `examples` folder. Likewise, use
```yaml
- uses: julia-actions/julia-processcoverage@v1
with:
directories: path/to/subdir/package/src
- uses: codecov/codecov-action@v2
with:
files: lcov.info
```
to get coverage information from a package in a subdirectory of the repo.

View File

@@ -1,27 +0,0 @@
import {wait} from '../src/wait'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
test('throws invalid number', async () => {
const input = parseInt('foo', 10)
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
})
test('wait 500 ms', async () => {
const start = new Date()
await wait(500)
const end = new Date()
var delta = Math.abs(end.getTime() - start.getTime())
expect(delta).toBeGreaterThan(450)
})
// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['INPUT_MILLISECONDS'] = '500'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecSyncOptions = {
env: process.env
}
console.log(cp.execSync(`node ${ip}`, options).toString())
})

View File

@@ -1,6 +1,21 @@
name: 'Process Julia coverage files' name: 'Process Julia coverage files'
description: 'Convert Julia coverage files into a lcov file' description: 'Convert Julia coverage files into a lcov file'
author: 'David Anthoff' author: 'David Anthoff'
branding:
icon: 'settings'
color: 'gray-dark'
inputs:
directories:
description: 'Comma-separated list of directories to look for coverage information (e.g. `src,examples`)'
required: false
default: 'src,ext'
runs: runs:
using: 'node12' using: 'composite'
main: 'dist/index.js' steps:
- run: julia --color=yes "$GITHUB_ACTION_PATH"/main.jl
shell: bash
env:
INPUT_DIRECTORIES: ${{ inputs.directories }}

1553
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

20
main.jl Normal file
View File

@@ -0,0 +1,20 @@
using Pkg
Pkg.activate("coveragetempenv", shared=true)
Pkg.add(PackageSpec(name="CoverageTools"))
using CoverageTools
directories = get(ENV, "INPUT_DIRECTORIES", "src,ext")
dirs = filter!(!isempty, split(directories, ","))
for dir in dirs
if dir == "ext"
continue # Silently skip this directory
elseif !isdir(dir)
error("directory \"$dir\" not found!")
end
end
filter!(isdir, dirs)
pfs = mapreduce(process_folder, vcat, dirs)
LCOV.writefile("lcov.info", pfs)

6536
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,46 +0,0 @@
{
"name": "julia-processcoverage",
"version": "1.0.0",
"private": true,
"description": "TypeScript template action",
"main": "lib/main.js",
"scripts": {
"build": "tsc",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"pack": "ncc build",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/julia-actions/julia-processcoverage.git"
},
"keywords": [
"actions",
"node",
"setup"
],
"author": "David Anthoff",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/exec": "^1.0.3"
},
"devDependencies": {
"@types/jest": "^24.0.23",
"@types/node": "^12.7.12",
"@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^5.16.0",
"eslint-plugin-github": "^2.0.0",
"eslint-plugin-jest": "^22.21.0",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"js-yaml": "^3.13.1",
"prettier": "^1.19.1",
"ts-jest": "^24.2.0",
"typescript": "^3.6.4"
}
}

View File

@@ -1,11 +0,0 @@
using Pkg
Pkg.activate("coveragetempenv", shared=true)
Pkg.add(PackageSpec(name="CoverageTools"))
using CoverageTools
pf = process_folder()
LCOV.writefile("lcov.info", pf)

View File

@@ -1,20 +0,0 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as path from 'path';
async function run(): Promise<void> {
try {
if (require.main) {
let rootPath = path.normalize(path.join(path.dirname(require.main.filename), '..'));
await exec.exec('julia', ['--color=yes', path.join(rootPath, 'src', 'main.jl')]);
}
else {
core.setFailed('Require method to load root path did not work.')
}
} catch (error) {
core.setFailed(error.message)
}
}
run()

View File

@@ -1,12 +0,0 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"exclude": ["node_modules", "**/*.test.ts"]
}