-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from ideal-postcodes/10.0.0
10.0.0
- Loading branch information
Showing
57 changed files
with
3,626 additions
and
1,812 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,54 @@ | ||
version: 2 | ||
--- | ||
default_steps: &default_steps | ||
steps: | ||
- run: | ||
command: "dockerize -wait tcp://localhost:5432 -timeout 2m" | ||
name: "Wait for db" | ||
- checkout | ||
- run: "sudo apt-get update" | ||
- run: "sudo apt install postgresql-client" | ||
- run: "POSTGRES_USER=postgres npm run setup_test_db" | ||
- restore_cache: | ||
keys: | ||
- "nodemodules-deps-{{ checksum \"package-lock.json\" }}" | ||
- run: "npm install" | ||
- save_cache: | ||
key: "nodemodules-deps-{{ checksum \"package-lock.json\" }}" | ||
paths: | ||
- node_modules/ | ||
- run: "npm run test" | ||
- run: "npm run coverage" | ||
jobs: | ||
node6: | ||
docker: | ||
- image: circleci/node:6.10 | ||
environment: | ||
- PGHOST=localhost | ||
- PGUSER=postgres | ||
- image: circleci/postgres:9.6-alpine-postgis | ||
steps: | ||
- run: | ||
name: Wait for db | ||
command: dockerize -wait tcp://localhost:5432 -timeout 2m | ||
- checkout | ||
- run: sudo apt-get update | ||
- run: sudo apt install postgresql-client | ||
- run: POSTGRES_USER=postgres npm run setup_test_db | ||
- restore_cache: | ||
keys: | ||
- nodemodules-deps-{{ checksum "package-lock.json" }} | ||
- nodemodules-deps- | ||
- run: npm install | ||
- save_cache: | ||
key: nodemodules-deps-{{ checksum "package-lock.json" }} | ||
paths: | ||
- node_modules/ | ||
- run: npm run test | ||
- run: npm run coverage | ||
|
||
|
||
node8: | ||
docker: | ||
- image: circleci/node:8.8 | ||
environment: | ||
- PGHOST=localhost | ||
- PGUSER=postgres | ||
- image: circleci/postgres:9.6-alpine-postgis | ||
steps: | ||
- run: | ||
name: Wait for db | ||
command: dockerize -wait tcp://localhost:5432 -timeout 2m | ||
- checkout | ||
- run: sudo apt-get update | ||
- run: sudo apt install postgresql-client | ||
- run: POSTGRES_USER=postgres npm run setup_test_db | ||
- restore_cache: | ||
keys: | ||
- nodemodules-deps-{{ checksum "package-lock.json" }} | ||
- nodemodules-deps- | ||
- run: npm install | ||
- save_cache: | ||
key: nodemodules-deps-{{ checksum "package-lock.json" }} | ||
paths: | ||
- node_modules/ | ||
- run: npm run test | ||
- run: npm run coverage | ||
node10: | ||
docker: | ||
- image: circleci/node:10 | ||
environment: | ||
- PGHOST=localhost | ||
- PGUSER=postgres | ||
- image: circleci/postgres:9.6-alpine-postgis | ||
steps: | ||
- run: | ||
name: Wait for db | ||
command: dockerize -wait tcp://localhost:5432 -timeout 2m | ||
- checkout | ||
- run: sudo apt-get update | ||
- run: sudo apt install postgresql-client | ||
- run: POSTGRES_USER=postgres npm run setup_test_db | ||
- restore_cache: | ||
keys: | ||
- nodemodules-deps-{{ checksum "package-lock.json" }} | ||
- nodemodules-deps- | ||
- run: npm install | ||
- save_cache: | ||
key: nodemodules-deps-{{ checksum "package-lock.json" }} | ||
paths: | ||
- node_modules/ | ||
- run: npm run test | ||
- run: npm run coverage | ||
|
||
node10: | ||
<<: *default_steps | ||
docker: | ||
- environment: | ||
- PGHOST=localhost | ||
- PGUSER=postgres | ||
image: "circleci/node:10" | ||
- image: "circleci/postgres:10-alpine-postgis" | ||
node11: | ||
<<: *default_steps | ||
docker: | ||
- environment: | ||
- PGHOST=localhost | ||
- PGUSER=postgres | ||
image: "circleci/node:11" | ||
- image: "circleci/postgres:10-alpine-postgis" | ||
node8: | ||
<<: *default_steps | ||
docker: | ||
- environment: | ||
- PGHOST=localhost | ||
- PGUSER=postgres | ||
image: "circleci/node:8" | ||
- image: "circleci/postgres:10-alpine-postgis" | ||
version: 2 | ||
workflows: | ||
version: 2 | ||
node6_node8_node10: | ||
supported_nodes: | ||
jobs: | ||
- node6 | ||
- node8 | ||
- node10 | ||
|
||
- node11 | ||
version: 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
POSTGRES_DB=postcodesiodb | ||
POSTGRES_PASSWORD=secret | ||
POSTGRES_USER=postcodesio | ||
POSTGRES_HOST=db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ process.json | |
log/ | ||
npm-debug.log | ||
*.swp | ||
*.vim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
FROM mdillon/postgis:9.6 | ||
FROM mdillon/postgis:10-alpine | ||
|
||
# Copy the pointer to the latest pg_dump | ||
COPY latest /tmp/latest | ||
|
||
# Download and decompress latest pg_dump into image to be loaded on container startup | ||
RUN apt-get update && \ | ||
apt-get install wget -y && \ | ||
wget -nv -O - $(cat /tmp/latest) > /docker-entrypoint-initdb.d/_postcodesiodata.sql.gz | ||
RUN mkdir -p /docker-entrypoint-initdb.d/ && \ | ||
apk add --no-cache curl && \ | ||
curl -o /docker-entrypoint-initdb.d/_postcodesiodata.sql.gz $(cat /tmp/latest) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use strict"; | ||
|
||
const { series } = require("async"); | ||
const models = require("../models/index.js"); | ||
const { Outcode } = models; | ||
|
||
// List of support tables generated from data/ directory | ||
const SUPPORT_TABLES = [ | ||
"Ccg", | ||
"Ced", | ||
"Constituency", | ||
"County", | ||
"District", | ||
"Nuts", | ||
"Parish", | ||
"Ward", | ||
].map(name => models[name]); | ||
|
||
/** | ||
* Generates support tables in DB | ||
* | ||
* @returns {Promise} | ||
*/ | ||
const setupSupportTables = () => { | ||
return new Promise((resolve, reject) => { | ||
series(SUPPORT_TABLES.map(m => m._setupTable.bind(m)), (error, result) => { | ||
if (error) return reject(error); | ||
return resolve(result); | ||
}); | ||
}); | ||
}; | ||
|
||
/** | ||
* Generates outcodes from existing postcodes relation | ||
* | ||
* @returns {Promise} | ||
*/ | ||
const setupOutcodeTable = () => { | ||
return new Promise((resolve, reject) => { | ||
Outcode._setupTable((error, result) => { | ||
if (error) return reject(error); | ||
return resolve(result); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = { | ||
setupSupportTables, | ||
setupOutcodeTable, | ||
SUPPORT_TABLES, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.