diff --git a/.github/main.workflow b/.github/main.workflow new file mode 100644 index 0000000..95c7937 --- /dev/null +++ b/.github/main.workflow @@ -0,0 +1,8 @@ +workflow "Validate Commit Messages" { + on = "push" + resolves = "Prevent Fixup Commits" +} + +action "Prevent Fixup Commits" { + uses = "ianwremmel/prevent-fixup-commits@v1.0.0" +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0afc99a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,20 @@ +{ + "arrowParens": "always", + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true, + "trailingComma": "es5", + "bracketSpacing": false, + "jsxBracketSameLine": false, + "proseWrap": "always", + "overrides": [ + { + "files": "*.md", + "options": { + "tabWidth": 4 + } + } + ] +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..70f6650 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM bash:5.0.7 + +LABEL version="1.0.0" +LABEL repository="http://github.com/check-run-reporter/action" +LABEL homepage="http://github.com/check-run-reporter/action" +LABEL maintainer="Ian Remmel, LLC " + +LABEL com.github.actions.name="Check Run Reporter" +LABEL com.github.actions.description="Upload structure reports to check-run-reporter.com" +LABEL com.github.actions.icon="check" +LABEL com.github.actions.color="orange" + +RUN apk add curl + +COPY "entrypoint" "/entrypoint" +ENTRYPOINT ["/entrypoint"] +CMD ["entrypoint"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..55a696b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Ian Remmel, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e452ca3 --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# GitHub Actions for Check Run Reporter _(check-run-reporter/action)_ + +> A GitHub action for uploading structured test reports to +> [check-run-reporter.com](https://www.check-run-reporter.com). + +## Usage + +First, get your `CHECK_RUN_REPORTER_REPO_TOKEN` from +[check-run-reporter.com](https://check-run-reporter.com/repos) and set it as a +[secret in your GitHub repo](https://developer.github.com/actions/managing-workflows/storing-secrets/). + +Use `CHECK_RUN_REPORTER_LABEL` and `CHECK_RUN_REPORTER_REPORT_GLOB` to tell the +action where your report(s) are and how to label them when they're uploaded. The +example below shows how you might configure a JavaScript project to upload +multiple JUnit reports. + +```hcl +workflow "Test" { + on = "push" + resolves = "Report" +} + +action "Install" { + uses = "actions/npm@master" + + args = "ci" +} + +action "Test" { + needs "Install" + uses "actions/npm@master" + args = "test" + + env = { + REPORT_DIR = "reports/junit" + } +} + +action "Report" { + uses = "check-run-reporter/actions" + + secrets = ["CHECK_RUN_REPORTER_REPO_TOKEN"] + + env = { + CHECK_RUN_REPORTER_LABEL = "Unit Tests" + CHECK_RUN_REPORTER_REPORT_GLOB = "reports/junit/**/*.xml" + } +} +``` + +> You can declare the action multiple times if you'd like to do separate +> submissions with different labels (for example, you want separate style report +> and test report submissions). + +## API + +`CHECK_RUN_REPORTER_REPO_TOKEN`: (required, secret) The token used to +authenticate the report submission to check-run-reporter.com. +`CHECK_RUN_REPORTER_LABEL`: (optional, environment) The label used for the +submitted reports `CHECK_RUN_REPORTER_REPORT_GLOB`: (required, environment) A +bash-style (`shopt -s globstar`) shell glob for identifying all of the reports +to submit. + +## Maintainers + +[Ian Remmel](https://github.com/ianwremmel) + +## Contributing + +We welcome pull requests, but for anything more than a minor tweak, please +create an issue for so we can discuss whether the change is the right direction +for the project. + +## License + +[MIT](LICENSE) © Ian Remmel, LLC 2019 diff --git a/entrypoint b/entrypoint new file mode 100755 index 0000000..a6429b2 --- /dev/null +++ b/entrypoint @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -euo pipefail +shopt -s globstar + +log () { + echo "$@" +} + +if [ "$CHECK_RUN_REPORTER_REPO_TOKEN" == '' ]; then + log 'CHECK_RUN_REPORTER_REPO_TOKEN is required' + exit 1 +fi + +if [ "$CHECK_RUN_REPORTER_REPORT_GLOB" == '' ]; then + log 'CHECK_RUN_REPORTER_REPORT_GLOB is required' + exit 1 +fi + +CHECK_RUN_REPORTER_LABEL="${CHECK_RUN_REPORTER_LABEL:-'Checks'}" + +CMD='curl https://www.check-run-reporter.com/api/v1/submissions' +CMD+=" --user token:$CHECK_RUN_REPORTER_REPO_TOKEN" +CMD+=" -F root=$(pwd)" +CMD+=" -F sha=$GITHUB_SHA" +CMD+=" -F label=$CHECK_RUN_REPORTER_LABEL" + +for FILE in $CHECK_RUN_REPORTER_REPORT_GLOB; do + CMD+=" -F $FILE" +done + +$CMD \ No newline at end of file diff --git a/playground.sh b/playground.sh new file mode 100755 index 0000000..76791f2 --- /dev/null +++ b/playground.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail +shopt -s globstar + +GLOB='**/*' + +for FILE in $GLOB; do + echo $FILE +done \ No newline at end of file