Skip to content

Commit 292b792

Browse files
authored
Merge pull request #275 from minrk/actions
travis -> github actions
2 parents d41f67c + 6057eb2 commit 292b792

14 files changed

+498
-403
lines changed

.github/workflows/npm-publish.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: upload-npm
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
publish-npm:
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v1
16+
with:
17+
node-version: 14
18+
registry-url: https://registry.npmjs.org/
19+
- run: npm ci
20+
- run: npm publish
21+
env:
22+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.github/workflows/test.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Useful GitHub Actions docs:
2+
#
3+
# - https://help.github.com/en/actions
4+
# - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
5+
# - https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow
6+
# - https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
7+
8+
name: test
9+
10+
on:
11+
- push
12+
- pull_request
13+
14+
jobs:
15+
# Job to run linter / autoformat
16+
17+
lint:
18+
runs-on: ubuntu-20.04
19+
steps:
20+
# Action Repo: https://github.com/actions/checkout
21+
- name: "Checkout repo"
22+
uses: actions/checkout@v2
23+
24+
# Action Repo: https://github.com/actions/setup-node
25+
- name: "Setup Node"
26+
uses: actions/setup-node@v1
27+
with:
28+
node-version: "14"
29+
30+
# Action Repo: https://github.com/actions/cache
31+
- name: "Cache node_modules"
32+
uses: actions/cache@v2
33+
with:
34+
path: node_modules
35+
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
36+
restore-keys: |
37+
${{ runner.os }}-npm-
38+
39+
- name: "Install"
40+
run: |
41+
npm ci
42+
43+
- name: "`npm run fmt` and check for changes"
44+
run: |
45+
# If this fails, run `npm run fmt` and push the result
46+
# amend if you feel so inclined.
47+
npm run fmt
48+
git diff --exit-code
49+
50+
- name: npm audit
51+
run: |
52+
# If this fails, run `npm audit fix`
53+
npm audit --production --audit-level=moderate
54+
55+
test:
56+
# no need to wait for lint
57+
# needs: lint
58+
runs-on: ubuntu-20.04
59+
# - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategy
60+
strategy:
61+
fail-fast: false # Do not cancel all jobs if one fails
62+
matrix:
63+
node_version:
64+
- "10"
65+
- "12"
66+
- "14"
67+
- "15"
68+
69+
steps:
70+
- name: "Checkout repo"
71+
uses: actions/checkout@v2
72+
73+
# Action Repo: https://github.com/actions/setup-node
74+
- name: "Setup Node"
75+
uses: actions/setup-node@v1
76+
with:
77+
node-version: ${{ matrix.node_version }}
78+
79+
# Action Repo: https://github.com/actions/cache
80+
- name: "Cache node_modules"
81+
uses: actions/cache@v2
82+
with:
83+
path: node_modules
84+
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
85+
restore-keys: |
86+
${{ runner.os }}-npm-
87+
88+
- name: "Install dependencies"
89+
run: |
90+
npm ci
91+
92+
- name: "Run tests"
93+
run: |
94+
npm test
95+
96+
# Action Repo: https://github.com/codecov/codecov-action
97+
- name: "Upload coverage to codecov"
98+
uses: codecov/codecov-action@v1

.travis.yml

-45
This file was deleted.

bin/configurable-http-proxy

+17-19
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ args
6767
"--redirect-port <redirect-port>",
6868
"Redirect HTTP requests on this port to the server on HTTPS"
6969
)
70-
.option(
71-
"--redirect-to <port>",
72-
"Redirect HTTP requests from --redirect-port to this port")
70+
.option("--redirect-to <port>", "Redirect HTTP requests from --redirect-port to this port")
7371
.option("--pid-file <pid-file>", "Write our PID to a file")
7472
// passthrough http-proxy options
7573
.option("--no-x-forward", "Don't add 'X-forward-' headers to proxied requests")
@@ -84,7 +82,8 @@ args
8482
.option(
8583
"--custom-header <header>",
8684
"Custom header to add to proxied requests. Use same option for multiple headers (--custom-header k1:v1 --custom-header k2:v2)",
87-
collectHeadersIntoObject, {}
85+
collectHeadersIntoObject,
86+
{}
8887
)
8988
.option("--insecure", "Disable SSL cert verification")
9089
.option("--host-routing", "Use host routing (host as first level of path)")
@@ -110,12 +109,12 @@ args
110109
// collects multiple flags to an object
111110
// --custom-header "k1:v1" --custom-header " k2 : v2 " --> {"k1":"v1","k2":"v2"}
112111
function collectHeadersIntoObject(value, previous) {
113-
var headerParts = value.split(":").map(p => p.trim())
112+
var headerParts = value.split(":").map((p) => p.trim());
114113
if (headerParts.length != 2) {
115114
log.error("A single colon was expected in custom header: " + value);
116115
process.exit(1);
117116
}
118-
previous[headerParts[0]] = headerParts[1]
117+
previous[headerParts[0]] = headerParts[1];
119118
}
120119

121120
args.parse(process.argv);
@@ -206,7 +205,7 @@ if (args.apiSslKey || args.apiSslCert) {
206205
var chain = fs.readFileSync(args.apiSslCa, "utf8");
207206
var ca = [];
208207
var cert = [];
209-
chain.split("\n").forEach(function(line) {
208+
chain.split("\n").forEach(function (line) {
210209
cert.push(line);
211210
if (line.match(/-END CERTIFICATE-/)) {
212211
ca.push(new Buffer(cert.join("\n")));
@@ -241,7 +240,7 @@ if (args.clientSslKey || args.clientSslCert) {
241240
var chain = fs.readFileSync(args.clientSslCa, "utf8");
242241
var ca = [];
243242
var cert = [];
244-
chain.split("\n").forEach(function(line) {
243+
chain.split("\n").forEach(function (line) {
245244
cert.push(line);
246245
if (line.match(/-END CERTIFICATE-/)) {
247246
ca.push(new Buffer(cert.join("\n")));
@@ -357,7 +356,7 @@ if (args.pidFile) {
357356
var fd = fs.openSync(args.pidFile, "w");
358357
fs.writeSync(fd, process.pid.toString());
359358
fs.closeSync(fd);
360-
process.on("exit", function() {
359+
process.on("exit", function () {
361360
log.debug("Removing %s", args.pidFile);
362361
fs.unlinkSync(args.pidFile);
363362
});
@@ -366,9 +365,9 @@ if (args.pidFile) {
366365
// Redirect HTTP to HTTPS on the proxy's port
367366
if (options.redirectPort && listen.port !== 80) {
368367
var http = require("http");
369-
var redirectPort = (options.redirectTo ? options.redirectTo : listen.port);
368+
var redirectPort = options.redirectTo ? options.redirectTo : listen.port;
370369
var server = http
371-
.createServer(function(req, res) {
370+
.createServer(function (req, res) {
372371
var host = req.headers.host.split(":")[0];
373372

374373
// Make sure that when we redirect, it's to the port the proxy is running on
@@ -379,30 +378,29 @@ if (options.redirectPort && listen.port !== 80) {
379378
res.writeHead(301, { Location: "https://" + host + req.url });
380379
res.end();
381380
})
382-
.listen(options.redirectPort, ()=>{
383-
log.info("Added HTTP to HTTPS redirection from "
384-
+ server.address().port
385-
+ " to "
386-
+ redirectPort);
381+
.listen(options.redirectPort, () => {
382+
log.info(
383+
"Added HTTP to HTTPS redirection from " + server.address().port + " to " + redirectPort
384+
);
387385
});
388386
}
389387

390388
// trigger normal exit on SIGINT
391389
// without this, PID cleanup won't fire on SIGINT
392-
process.on("SIGINT", function() {
390+
process.on("SIGINT", function () {
393391
log.warn("Interrupted");
394392
process.exit(2);
395393
});
396394

397395
// trigger normal exit on SIGTERM
398396
// fired on `docker stop` and during Kubernetes pod container evictions
399-
process.on("SIGTERM", function() {
397+
process.on("SIGTERM", function () {
400398
log.warn("Terminated");
401399
process.exit(2);
402400
});
403401

404402
// log uncaught exceptions, don't exit now that setup is complete
405-
process.on("uncaughtException", function(e) {
403+
process.on("uncaughtException", function (e) {
406404
log.error("Uncaught Exception: " + e.message);
407405
if (e.stack) {
408406
log.error(e.stack);

0 commit comments

Comments
 (0)