Skip to content

Commit

Permalink
Merge branch 'main' into reconcile
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSlome committed Feb 8, 2024
2 parents 4cc2da0 + dbcd124 commit 9903517
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 84 deletions.
34 changes: 7 additions & 27 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
pull_request:
branches: [ main ]

permissions:
pull-requests: write

jobs:
build:

Expand All @@ -19,9 +22,6 @@ jobs:
node-version: [18.x]
mongodb-version: [4.4]

permissions:
pull-requests: write

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
Expand All @@ -45,31 +45,11 @@ jobs:
run: |
npm run test-coverage-ci || echo "Silently ignoring coverage threshold limit..."
- name: Check if a valid lcov.info file is generated
id: check-lcov-non-empty
run: |
if [ -s "./coverage/lcov.info" ]; then
echo "lcov.info is not empty."
echo "isNotEmpty=true" >> $GITHUB_OUTPUT
else
echo "lcov.info is empty."
echo "isNotEmpty=false" >> $GITHUB_OUTPUT
fi
- name: Install LCOV
if: ${{ steps.check-lcov-non-empty.outputs.isNotEmpty == 'true'}}
run: |
sudo apt-get update && sudo apt-get install --assume-yes lcov
- name: Report code coverage
if: ${{ steps.check-lcov-non-empty.outputs.isNotEmpty == 'true' }}
uses: zgosalvez/github-actions-report-lcov@v4
- name: Upload test coverage report
uses: codecov/codecov-action@v4.0.1
with:
coverage-files: ./coverage/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true

files: ./coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
# - name: Exit if coverage condition not met
# if: ${{ steps.test.outputs.exit_code }} != 0
# run: exit ${{ steps.test.outputs.exit_code }}

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
[![FINOS - Incubating](https://cdn.jsdelivr.net/gh/finos/contrib-toolbox@master/images/badge-incubating.svg)](https://community.finos.org/docs/governance/Software-Projects/stages/incubating)
[![NPM](https://img.shields.io/npm/v/@finos/git-proxy?colorA=00C586&colorB=000000)](https://www.npmjs.com/package/@finos/git-proxy)
[![Build](https://img.shields.io/github/actions/workflow/status/finos/git-proxy/nodejs.yml?branch=main&label=CI&logo=github&colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/actions/workflows/nodejs.yml)
[![codecov](https://codecov.io/gh/finos/git-proxy/branch/main/graph/badge.svg)](https://codecov.io/gh/finos/git-proxy)
[![Documentation](https://img.shields.io/badge/_-documentation-000000?colorA=00C586&logo=docusaurus&logoColor=FFFFFF&)](https://git-proxy.finos.org)
<br />
[![License](https://img.shields.io/github/license/finos/git-proxy?colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/blob/main/LICENSEP)
[![License](https://img.shields.io/github/license/finos/git-proxy?colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/blob/main/LICENSE)
[![Contributors](https://img.shields.io/github/contributors/finos/git-proxy?colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/graphs/contributors)
[![Stars](https://img.shields.io/github/stars/finos/git-proxy?colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/stargazers)
[![Forks](https://img.shields.io/github/forks/finos/git-proxy?colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/forks)
Expand Down Expand Up @@ -85,7 +86,7 @@ customize for your environment, see the [project's documentation](https://git-pr

- [Quickstart](https://git-proxy.finos.org/docs/category/quickstart/)
- [Installation](https://git-proxy.finos.org/docs/installation)
- [Configuration](https://git-proxy.finos.org/docs/configuration)
- [Configuration](https://git-proxy.finos.org/docs/category/configuration)

## Contributing

Expand Down
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
34 changes: 1 addition & 33 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
/* eslint-disable max-len */
'use strict';

const { execFileSync } = require('child_process');

let opts = {
const opts = {
branches: 80,
lines: 80,
functions: 80,
statements: 80,
};

// Only generate coverage report for changed files in PR
// see: https://github.com/actions/checkout/issues/438#issuecomment-1446882066
// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if (process.env.GITHUB_BASE_REF !== undefined) {
console.log('Generating coverage report for changed files...');
try {
const baseRef = execFileSync('git', [
'rev-parse',
`origin/${process.env.GITHUB_BASE_REF}`,
])
.toString()
.replace('\n', '');
const headRef = process.env.GITHUB_SHA;
const stdout = execFileSync('git', [
'diff',
'--name-only',
`${baseRef}..${headRef}`,
]).toString();
opts = {
...opts,
include: stdout.split('\n'),
};
} catch (error) {
console.log('Error: ', error);
}
}

console.log('nyc config: ', opts);
module.exports = opts;
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"react-chartist": "0.14.4",
"react-dom": "^16.13.1",
"react-html-parser": "^2.0.2",
"react-router-dom": "6.21.3",
"react-router-dom": "6.22.0",
"uuid": "^9.0.0",
"yargs": "^17.7.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const proxyApp = require('express')();
const bodyParser = require('body-parser');
const routes = require('./routes');
const routes = require('./routes').router;
const { GIT_PROXY_SERVER_PORT: proxyHttpPort } = require('../config/env').Vars;

const options = {
Expand Down
18 changes: 11 additions & 7 deletions src/proxy/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ router.use(
message = action.blockedMessage;
}

// ERROR PCT LINE -- MOVE THIS TO HELPER
const errorMessage = `ERR\t${message}`;
const len = 6 + errorMessage.length;

const prefix = len.toString(16);
const packetMessage = `00${prefix}\x02${errorMessage}\n0000`;
packetMessage = handleMessage(message);

Check failure on line 46 in src/proxy/routes/index.js

View workflow job for this annotation

GitHub Actions / Linting

'packetMessage' is not defined

Check failure on line 46 in src/proxy/routes/index.js

View workflow job for this annotation

GitHub Actions / Linting

'packetMessage' is not defined

console.log(req.headers);

Expand Down Expand Up @@ -86,4 +81,13 @@ router.use(
}),
);

module.exports = router;
const handleMessage = async(message) => {
const errorMessage = `ERR\t${message}`;
const len = 6 + new TextEncoder().encode(errorMessage).length;

const prefix = len.toString(16);
const packetMessage = `${prefix.padStart(4, '0')}\x02${errorMessage}\n0000`;
return packetMessage
}

module.exports = {router, handleMessage};
19 changes: 19 additions & 0 deletions test/testProxyRoute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

const handleMessage = require('../src/proxy/routes').handleMessage;
const chai = require('chai');

const expect = chai.expect;

// Use this test as a template
describe('proxy error messages', async () => {

it('should handle short messages', async function () {
const res = await handleMessage('one');
expect(res).to.contain('one');
});

it('should handle emoji messages', async function () {
const res = await handleMessage('❌ push failed: too many errors');
expect(res).to.contain('❌');
});
});

0 comments on commit 9903517

Please sign in to comment.