Skip to content

Commit

Permalink
Migrate to GitHub Actions (#1104)
Browse files Browse the repository at this point in the history
* Create nodejs.yml

* Run only on push

* Renamed jobs

* Removed .travis.yml

* Split coverage job and cleanup

* Skip flaky test

* Code coverage reporting

* Renamed codecov file

* Added backport action

* Updated integration test configuration

* Removed unused dependencies

* Fixes
  • Loading branch information
delvedor authored Mar 10, 2020
1 parent 58a2618 commit 94d4ac7
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 63 deletions.
46 changes: 15 additions & 31 deletions .ci/run-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,30 @@ echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
echo -e "\033[34;1mINFO:\033[0m TEST_SUITE ${TEST_SUITE}\033[0m"
echo -e "\033[34;1mINFO:\033[0m URL ${ELASTICSEARCH_URL}\033[0m"
echo -e "\033[34;1mINFO:\033[0m CONTAINER ${elasticsearch_container}\033[0m"
echo -e "\033[34;1mINFO:\033[0m DOTNET_VERSION ${NODE_JS_VERSION}\033[0m"
echo -e "\033[34;1mINFO:\033[0m NODE_JS_VERSION ${NODE_JS_VERSION}\033[0m"

echo -e "\033[1m>>>>> Build docker container >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"

set +x
export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID")
export CODECOV_TOKEN=$(vault read -field=token secret/clients-ci/elasticsearch-js/codecov)
unset VAULT_ROLE_ID VAULT_SECRET_ID VAULT_TOKEN
set -x

docker build \
--file .ci/Dockerfile \
--tag elastic/elasticsearch-js \
--build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \
.

echo -e "\033[1m>>>>> NPM run ci >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
echo -e "\033[1m>>>>> NPM run test:integration >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"

repo=$(realpath $(dirname $(realpath -s $0))/../)

if [[ $TEST_SUITE != "xpack" ]]; then
docker run \
--network=${network_name} \
--env "TEST_ES_SERVER=${ELASTICSEARCH_URL}" \
--env "CODECOV_TOKEN" \
--volume $repo:/usr/src/app \
--volume /usr/src/app/node_modules \
--name elasticsearch-js \
--rm \
elastic/elasticsearch-js \
npm run ci
else
docker run \
--network=${network_name} \
--env "TEST_ES_SERVER=${ELASTICSEARCH_URL}" \
--env "CODECOV_TOKEN" \
--volume $repo:/usr/src/app \
--volume /usr/src/app/node_modules \
--name elasticsearch-js \
--rm \
elastic/elasticsearch-js \
npm run test:integration
run_script_args=""
if [[ "$NODE_JS_VERSION" == "8" ]]; then
run_script_args="-- --node-arg=--harmony-async-iteration"
fi

docker run \
--network=${network_name} \
--env "TEST_ES_SERVER=${ELASTICSEARCH_URL}" \
--volume $repo:/usr/src/app \
--volume /usr/src/app/node_modules \
--name elasticsearch-js \
--rm \
elastic/elasticsearch-js \
npm run test:integration ${run_script_args}
16 changes: 16 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Backport
on:
pull_request:
types:
- closed
- labeled

jobs:
backport:
runs-on: ubuntu-latest
name: Backport
steps:
- name: Backport
uses: tibdex/backport@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
120 changes: 120 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Node CI

on: [push]

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [10.x, 12.x, 13.x]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Unit test
run: |
npm run test:unit
- name: Behavior test
run: |
npm run test:behavior
- name: Type Definitions
run: |
npm run test:types
test-node-v8:
name: Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [8.x]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install
- name: Test
run: |
npm run test:unit -- --node-arg=--harmony-async-iteration
code-coverage:
name: Code coverage
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install
- name: Code coverage
run: |
npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.lcov
fail_ci_if_error: true

license:
name: License check
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: |
npm install
- name: License checker
run: |
npm run license-checker
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .codecov.yml → codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ comment: off
coverage:
precision: 2
round: down
range: "90...100"
range: "95...100"

status:
project: yes
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test:behavior": "tap test/behavior/*.test.js -t 300 --no-coverage",
"test:integration": "node test/integration/index.js",
"test:types": "tsc --project ./test/types/tsconfig.json",
"test:coverage": "nyc tap test/unit/*.test.js test/behavior/*.test.js -t 300 && nyc report --reporter=text-lcov > coverage.lcov && codecov",
"test:coverage": "nyc tap test/unit/*.test.js test/behavior/*.test.js -t 300 && nyc report --reporter=text-lcov > coverage.lcov",
"lint": "standard",
"lint:fix": "standard --fix",
"ci": "npm run license-checker && npm test && npm run test:integration && npm run test:coverage",
Expand All @@ -39,7 +39,6 @@
},
"devDependencies": {
"@types/node": "^12.6.2",
"codecov": "^3.3.0",
"convert-hrtime": "^3.0.0",
"dedent": "^0.7.0",
"deepmerge": "^4.0.0",
Expand All @@ -59,7 +58,6 @@
"standard": "^13.0.2",
"stoppable": "^1.1.0",
"tap": "^14.4.1",
"tap-mocha-reporter": "^4.0.1",
"typescript": "^3.4.5",
"workq": "^2.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/behavior/sniff.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ test('Should handle hostnames in publish_address', t => {
})
})

test('Sniff interval', t => {
test('Sniff interval', { skip: 'Flaky on CI' }, t => {
t.plan(10)

buildCluster(({ nodes, shutdown, kill }) => {
Expand Down

0 comments on commit 94d4ac7

Please sign in to comment.