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

Convert to JavaScript Action #29

Merged
merged 39 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
040078f
add a `package.json`
threeal Jan 25, 2023
dbf462b
add barebones for TypeScript actions
threeal Jan 25, 2023
4425914
add package command in the `package.json` and include `dist` directory
threeal Jan 25, 2023
61aa99f
change from using composite action to using JavaScript action
threeal Jan 25, 2023
88be77b
add install gcovr step
threeal Jan 25, 2023
46c5ece
add lint command in the `package.json` and fix lint
threeal Jan 25, 2023
5cca719
add format commands in the `package.json`
threeal Jan 25, 2023
e212eb2
add all command in the `package.json`
threeal Jan 25, 2023
0f403b0
fix missing `@vercel/ncc` for distributing this package
threeal Jan 26, 2023
57b8986
add `check-build` job in the `test.yml` workflow
threeal Jan 26, 2023
41193ed
add a step to chek if the distribution is up to date in the `check-bu…
threeal Jan 26, 2023
9062a63
use artifact to pass build from the `check-build` job to other jobs
threeal Jan 26, 2023
7972aa1
add a step to generate code coverage report using gcovr
threeal Jan 26, 2023
2816299
parse `root` action input
threeal Jan 26, 2023
9de4c68
add function to parse all action inputs
threeal Jan 26, 2023
67b0ecb
parse `gcov-executable` action input
threeal Jan 26, 2023
ce44910
put run gcovr step in a independent function
threeal Jan 26, 2023
00007d1
add gcovr `--exclude` argument
threeal Jan 26, 2023
095de1d
allow inputs to contains a null value
threeal Jan 26, 2023
f20a5dd
add gcovr `--fail-under-line` argument
threeal Jan 26, 2023
6e73ce4
separate `parseInputs` from gcovr
threeal Jan 27, 2023
824f401
add gcovr `--coveralls` argument
threeal Jan 27, 2023
753bb07
set the default Coveralls output if it's not set but send is enabled
threeal Jan 27, 2023
2b40202
include the `.git` directory to the artifact
threeal Jan 27, 2023
b92c14b
use `os.tmpdir()` to get temporary directory
threeal Jan 27, 2023
b3237b9
rename `src/inputs.ts` into `src/action.ts`
threeal Jan 27, 2023
868bb4f
add `gcov.check()` function to check if gcovr is installed
threeal Jan 27, 2023
3575f33
check and auto-install if `llvm-cov` is not available
threeal Jan 27, 2023
a00272d
move `gcovr.check` to `deps`
threeal Jan 27, 2023
605f9a1
send code coverage info to Coveralls
threeal Jan 27, 2023
f5d75b9
http get body even if status code is not ok
threeal Jan 27, 2023
e21c8bf
run other jobs for testing after `standard-usage` job is succes
threeal Jan 27, 2023
133288f
use `core.group()` in the `gcovr.run()`
threeal Jan 27, 2023
f051612
add `coveralls.patch` function to patch wrong gcovr's `service_name`
threeal Jan 27, 2023
1cd2e74
use `readFileSync` and `writeFileSync` instead in the `coveralls.patc…
threeal Jan 27, 2023
5134868
export `COVERALLS_REPO_TOKEN` if `github-token` input is set
threeal Jan 27, 2023
36eba65
catch all error to make the action failed
threeal Jan 27, 2023
44f12e3
better logging for describing each process
threeal Jan 27, 2023
5f7a9b6
audit codes
threeal Jan 27, 2023
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
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"plugins": ["@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"camelcase": "off",
"i18n-text/no-en": "off",
"import/no-namespace": "off"
},
"env": {
"node": true,
"es6": true
}
}
63 changes: 55 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,53 @@ on:
workflow_dispatch:
push:
jobs:
check-build:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/[email protected]

- name: Install dependencies
run: npm install

- name: Check formatting
run: npm run format-check

- name: Run static analysis
run: npm run lint

- name: Build this package
run: npm run build

- name: Build this package for distribution
run: npm run package

- name: Check if the distribution is up to date
run: git diff --exit-code HEAD

- name: Upload the distribution as an artifact
uses: actions/[email protected]
with:
name: dist
if-no-files-found: error
path: |
.git/
dist/
test/
action.yml

standard-usage:
needs: check-build
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Download the distribution artifact
uses: actions/[email protected]
with:
name: dist

- name: Configure and build the test project
uses: threeal/[email protected]
Expand All @@ -27,14 +65,17 @@ jobs:
uses: ./

llvm-usage:
needs: standard-usage
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Download the distribution artifact
uses: actions/[email protected]
with:
name: dist

- name: Configure and build the test project
uses: threeal/[email protected]
Expand All @@ -53,14 +94,17 @@ jobs:
gcov-executable: ${{ matrix.os == 'macos' && 'xcrun ' || '' }}llvm-cov gcov

exclusion-usage:
needs: standard-usage
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Download the distribution artifact
uses: actions/[email protected]
with:
name: dist

- name: Configure and build the test project
uses: threeal/[email protected]
Expand Down Expand Up @@ -99,14 +143,17 @@ jobs:
fail-under-line: 100

coveralls-usage:
needs: standard-usage
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
steps:
- name: Checkout this repository
uses: actions/[email protected]
- name: Download the distribution artifact
uses: actions/[email protected]
with:
name: dist

- name: Configure and build the test project
uses: threeal/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules
lib

build
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
68 changes: 2 additions & 66 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,69 +28,5 @@ inputs:
description: GitHub token of your project
required: false
runs:
using: composite
steps:
- name: Check if gcovr is installed
shell: bash
run: |
if ! command -v gcovr &> /dev/null; then
echo "gcovr could not be found, installing..."
pip3 install gcovr
fi

- name: Process inputs
shell: bash
run: |
if [ -n '${{ inputs.root }}' ]; then
ARGS="$ARGS --root '${{ inputs.root }}'"
fi
if [ -n '${{ inputs.gcov-executable }}' ]; then
ARGS="$ARGS --gcov-executable '${{ inputs.gcov-executable }}'"
fi
if [ -n '${{ inputs.exclude }}' ]; then
ARGS="$ARGS --exclude '${{ inputs.exclude }}'"
fi
if [ -n '${{ inputs.fail-under-line }}' ]; then
ARGS="$ARGS --fail-under-line '${{ inputs.fail-under-line }}'"
fi
if [ -n '${{ inputs.coveralls-out }}' ]; then
COVERALLS_OUT='${{ inputs.coveralls-out }}'
elif [ '${{ inputs.coveralls-send }}' = 'true' ]; then
COVERALLS_OUT='/tmp/coveralls.json'
fi
if [ -n "$COVERALLS_OUT" ]; then
ARGS="$ARGS --coveralls $COVERALLS_OUT"
fi
if [ -n '${{ inputs.github-token }}' ]; then
ENVS="$ENVS COVERALLS_REPO_TOKEN=${{ inputs.github-token }}"
fi
echo "GCOVR_ENVS=$ENVS" >> $GITHUB_ENV
echo "GCOVR_ARGS=$ARGS" >> $GITHUB_ENV
echo "COVERALLS_OUT=$COVERALLS_OUT" >> $GITHUB_ENV

- name: Check if LLVM coverage is installed
if: contains(inputs.gcov-executable, 'llvm-cov')
shell: bash
run: |
if ! command -v llvm-cov &> /dev/null; then
echo "llvm-cov could not be found, installing..."
case "$OSTYPE" in
darwin*) brew install llvm ;;
linux*) sudo apt-get install -y llvm ;;
*) choco install -y llvm ;;
esac
fi

- name: Generate code coverage report using gcovr
shell: bash
run: |
${{ env.GCOVR_ENVS }} gcovr ${{ env.GCOVR_ARGS }}
if [ -e '${{ env.COVERALLS_OUT }}' ]; then
# TODO: patch wrong service name generated by gcovr
sed -i'' -e 's/"service_name": "github-actions-ci"/"service_name": "github"/' '${{ env.COVERALLS_OUT }}'
fi

- name: Send code coverage report to Coveralls
if: ${{ inputs.coveralls-send == 'true' }}
shell: bash
run: curl -v -F json_file=@${{ env.COVERALLS_OUT }} https://coveralls.io/api/v1/jobs
using: node16
main: dist/index.js
Loading