Skip to content

Commit 97ed5e8

Browse files
committed
Switching to official Docker GitHub Actions
run actions on every push and pr
1 parent 6836c98 commit 97ed5e8

File tree

9 files changed

+41
-82
lines changed

9 files changed

+41
-82
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
**/.node_repl_history
3737

3838
.git
39+
.github

.eslintrc.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
module.exports = {
2-
plugins: [
3-
'standard',
4-
'prettier',
5-
'import',
6-
],
2+
plugins: ['standard'],
73
extends: [
84
'eslint:recommended',
5+
// Adds 'promise'/'import'/'node' plugins and configurations
96
'standard',
10-
'prettier',
7+
// Adds 'prettier' plugin
8+
'plugin:prettier/recommended',
119
'prettier/standard',
1210
],
1311
parserOptions: {
@@ -19,18 +17,18 @@ module.exports = {
1917
es6: true,
2018
},
2119
rules: {
22-
// fixable - errors
23-
'prettier/prettier': [
20+
// Fixable - errors
21+
'one-var': [
2422
'error',
23+
{
24+
const: 'never',
25+
let: 'never',
26+
},
2527
],
26-
'one-var': ['error', {
27-
const: 'never',
28-
let: 'never',
29-
}],
3028
'dot-notation': 'error',
3129
'no-else-return': ['error', {allowElseIf: false}],
3230
'capitalized-comments': 'error',
33-
//'linebreak-style': 'off',
31+
// 'linebreak-style': 'off',
3432
'lines-between-class-members': 'error',
3533
'multiline-comment-style': 'error',
3634
'no-lonely-if': 'error',
@@ -46,12 +44,12 @@ module.exports = {
4644
'prefer-template': 'error',
4745
'sort-imports': 'error',
4846

49-
// non-fixable - warnings
47+
// Non-fixable - warnings
5048
'no-await-in-loop': 'warn',
5149
'array-callback-return': 'warn',
5250
'block-scoped-var': 'warn',
53-
//'class-methods-use-this': 'warn',
54-
'complexity': 'warn',
51+
// 'class-methods-use-this': 'warn',
52+
complexity: 'warn',
5553
'consistent-return': 'warn',
5654
'default-case': 'warn',
5755
'guard-for-in': 'warn',
@@ -60,13 +58,13 @@ module.exports = {
6058
'no-implicit-globals': 'warn',
6159
'no-invalid-this': 'warn',
6260
'no-loop-func': 'warn',
63-
//'no-magic-numbers': 'warn',
61+
// 'no-magic-numbers': 'warn',
6462
'no-param-reassign': 'warn',
6563
'no-script-url': 'warn',
6664
'no-useless-concat': 'warn',
6765
'no-void': 'warn',
6866
'no-warning-comments': 'warn',
69-
'radix': 'warn',
67+
radix: 'warn',
7068
'require-await': 'warn',
7169
'init-declarations': 'warn',
7270
'no-catch-shadow': 'warn',
@@ -81,7 +79,7 @@ module.exports = {
8179
'consistent-this': 'warn',
8280
'func-name-matching': 'warn',
8381
'func-names': 'warn',
84-
'func-style': ['warn', 'declaration', {"allowArrowFunctions": true}],
82+
'func-style': ['warn', 'declaration', {allowArrowFunctions: true}],
8583
'line-comment-position': 'warn',
8684
'max-depth': 'warn',
8785
'max-nested-callbacks': 'warn',
Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
name: Docker
22

3-
on:
4-
push:
5-
# Publish `master` as Docker `latest` image.
6-
branches:
7-
- master
8-
9-
# Publish `v1.2.3` tags as releases.
10-
tags:
11-
- v*
12-
13-
# Run tests for any PRs.
14-
pull_request:
15-
16-
env:
17-
IMAGE_NAME: osmexport
3+
on: [push, pull_request]
184

195
jobs:
206
# Run tests.
@@ -27,52 +13,30 @@ jobs:
2713

2814
- name: Run tests
2915
run: |
30-
if [ -f docker-compose.test.yml ]; then
31-
docker-compose --file docker-compose.test.yml build
32-
docker-compose --file docker-compose.test.yml run sut
16+
if [ -f docker/docker-compose.test.yml ]; then
17+
docker-compose --file docker/docker-compose.test.yml build
18+
docker-compose --file docker/docker-compose.test.yml run sut
3319
else
34-
docker build . --file Dockerfile
20+
docker build --file docker/Dockerfile .
3521
fi
3622
3723
# Push image to GitHub Packages.
38-
# See also https://docs.docker.com/docker-hub/builds/
3924
push:
40-
# Ensure test job passes before pushing image.
4125
needs: test
4226

4327
runs-on: ubuntu-latest
44-
if: github.event_name == 'push'
4528

4629
steps:
4730
- uses: actions/checkout@v2
48-
49-
- name: Set image id
50-
run: |
51-
IMAGE_ID="docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME"
52-
IMAGE_ID=$(echo ${IMAGE_ID} | tr '[A-Z]' '[a-z]')
53-
echo "::set-env name=IMAGE_ID::${IMAGE_ID}"
54-
55-
- name: Build image
56-
run: |
57-
# Strip git ref prefix from version
58-
BRANCH_NAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
59-
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
60-
# Strip "v" prefix from tag name
61-
VERSION=$(echo $BRANCH_NAME | sed -e 's/^v//')
62-
LATEST_TAG="--tag ${IMAGE_ID}:latest"
63-
else
64-
FULL_SHA=${{ github.sha }}
65-
SHA7=${FULL_SHA:0:7}
66-
VERSION="${BRANCH_NAME}_${SHA7}"
67-
LATEST_TAG=""
68-
fi
69-
70-
TAG="--tag ${IMAGE_ID}:${VERSION}"
71-
echo "docker build . --file Dockerfile ${TAG} ${LATEST_TAG}"
72-
docker build . --file Dockerfile ${TAG} ${LATEST_TAG}
73-
74-
- name: Log into registry
75-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
7631

77-
- name: Push image
78-
run: docker push ${IMAGE_ID}
32+
- name: Build and push Docker images
33+
uses: docker/build-push-action@v1.1.0
34+
with:
35+
repository: atgardner/osmexport/osmexport
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
registry: docker.pkg.github.com
39+
dockerfile: docker/Dockerfile
40+
tag_with_ref: true
41+
tag_with_sha: true
42+
add_git_labels: true
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: '3.7'
22
services:
33
osmexport:
44
build:
5-
context: .
6-
dockerfile: Dockerfile
5+
context: ../
6+
dockerfile: docker/Dockerfile
77
image: noamgal/osmexport:latest
88
container_name: osmexport
99
ports:

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"cmd": "node commandLine.js"
1010
},
1111
"author": "",
12-
"type": "module",
1312
"license": "ISC",
1413
"devDependencies": {
1514
"chai": "^4.2.0",

src/app.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ app.get('/osm2gpx', async ({query, query: {relationId}, visitor}, res) => {
6262
const safeFileName = encodeURI(
6363
slug(fileName, {
6464
// Replace spaces with replacement
65-
replacement: c => c,
65+
replacement: (c) => c,
6666
// Replace unicode symbols or not
6767
symbols: false,
6868
// (optional) regex to remove characters
@@ -84,10 +84,7 @@ app.get('/osm2gpx', async ({query, query: {relationId}, visitor}, res) => {
8484
const end = moment().diff(start);
8585
sendTiming(visitor, 'failureTime', end);
8686
sendEvent(visitor, 'Error', `${relationId} - ${error}`);
87-
res
88-
.set('Content-Type', 'text/plain')
89-
.status(500)
90-
.send(error.stack);
87+
res.set('Content-Type', 'text/plain').status(500).send(error.stack);
9188
}
9289
});
9390

src/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
import winston from 'winston';
4-
// import {createLogger, format, transports} from 'winston';
4+
// Import {createLogger, format, transports} from 'winston';
55

66
const {combine, timestamp, label, simple} = winston.format;
77

src/osm2gpx.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function addMarkers({geometry: {coordinates, type}}, markerDiff) {
7575
let prevDistance = 0;
7676
let prevMarker = 0;
7777
let prevLatLon = 0;
78-
ways.forEach(way => {
78+
ways.forEach((way) => {
7979
way.forEach(([lon, lat]) => {
8080
if (prevLatLon) {
8181
const latLon = new LatLon(lat, lon);
@@ -110,7 +110,7 @@ export async function getRelation({
110110
reverse,
111111
}) {
112112
const geoJson = await getFullRelation(relationId);
113-
const relation = geoJson.features.find(f => f.id.startsWith('relation'));
113+
const relation = geoJson.features.find((f) => f.id.startsWith('relation'));
114114
if (reverse) {
115115
relation.geometry.coordinates.reverse();
116116
}

0 commit comments

Comments
 (0)