Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 48ff1b0

Browse files
authored
Set up project structure, docker, ci (mozilla#1)
1 parent d6f3f02 commit 48ff1b0

File tree

10 files changed

+1437
-1
lines changed

10 files changed

+1437
-1
lines changed

.circleci/config.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
version: 2.1
2+
3+
orbs:
4+
gcp-gcr: circleci/[email protected]
5+
6+
commands:
7+
restore-docker:
8+
description: Restore Docker image cache
9+
steps:
10+
- setup_remote_docker
11+
- restore_cache:
12+
key: v1-{{.Branch}}
13+
- run:
14+
name: Restore Docker image cache
15+
command: docker load -i /cache/docker.tar
16+
17+
jobs:
18+
build:
19+
docker:
20+
- image: docker:stable-git
21+
steps:
22+
- checkout
23+
- setup_remote_docker
24+
- run:
25+
name: Build Docker image
26+
command: docker build -t app:build .
27+
- run:
28+
name: docker save app:build
29+
command: mkdir -p /cache; docker save -o /cache/docker.tar "app:build"
30+
- save_cache:
31+
key: v1-{{ .Branch }}-{{epoch}}
32+
paths:
33+
- /cache/docker.tar
34+
35+
test:
36+
docker:
37+
- image: docker:18.06.0-ce
38+
steps:
39+
- restore-docker
40+
- run:
41+
name: Test Code
42+
command: docker run app:build yarn test
43+
44+
workflows:
45+
main:
46+
jobs:
47+
- build
48+
49+
- test:
50+
requires:
51+
- build
52+
53+
- gcp-gcr/build-and-push-image:
54+
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1608958 for details
55+
context: data-eng-airflow-gcr
56+
image: app-store-analytics-export
57+
requires:
58+
- test
59+
filters:
60+
branches:
61+
only: master

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
package-lock.json
3+
yarn.lock

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/node_modules/

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:12-slim
2+
MAINTAINER Ben Wu <[email protected]>
3+
4+
# https://github.com/mozilla-services/Dockerflow/blob/master/docs/building-container.md
5+
ARG USER_ID="10001"
6+
ARG GROUP_ID="app"
7+
ARG HOME="/app"
8+
9+
ENV HOME=${HOME}
10+
RUN groupadd --gid ${USER_ID} ${GROUP_ID} && \
11+
useradd --create-home --uid ${USER_ID} --gid ${GROUP_ID} --home-dir ${HOME} ${GROUP_ID}
12+
13+
WORKDIR ${HOME}
14+
15+
COPY . .
16+
17+
RUN yarn
18+
19+
# Drop root and change ownership of the application folder to the user
20+
RUN chown -R ${USER_ID}:${GROUP_ID} ${HOME}
21+
USER ${USER_ID}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# apple-app-store-export
1+
# App Store Analytics Export
2+
23
Scripts for exporting app analytics to BigQuery

analytics_export/analyticsExport.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"use strict";
2+
3+
function startExport() {
4+
console.log("test");
5+
return "test";
6+
}
7+
8+
exports.startExport = startExport;

analytics_export/startExport.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
3+
const analyticsExport = require("./analyticsExport.js");
4+
5+
const argv = require("yargs")
6+
.describe("username", "App store connect user to authenticate with")
7+
.describe("password", "Password for the given app store connect user")
8+
.demandOption(["username", "password"])
9+
.argv;
10+
11+
const itc = require("itunesconnectanalytics");
12+
13+
analyticsExport.startExport();

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "app-store-analytics-export",
3+
"version": "0.1.0",
4+
"description": "Scripts for exporting app analytics to BigQuery",
5+
"main": "analytics_export/startExport.js",
6+
"repository": "https://github.com/mozilla/app-store-analytics-export.git",
7+
"author": "Ben Wu <[email protected]>",
8+
"license": "MPL-2.0",
9+
"scripts": {
10+
"export": "node analytics_export/startExport.js",
11+
"test": "mocha"
12+
},
13+
"dependencies": {
14+
"itunesconnectanalytics": "~0.5.0",
15+
"node-fetch": "^2.6.0",
16+
"request": "^2.88.2",
17+
"yargs": "^15.3.1"
18+
},
19+
"devDependencies": {
20+
"chai": "^4.2.0",
21+
"mocha": "^8.0.1"
22+
}
23+
}

test/testExport.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
3+
const analyticsExport = require("../analytics_export/analyticsExport.js");
4+
5+
const chai = require("chai");
6+
7+
chai.should();
8+
9+
describe("Export Functions", function () {
10+
it("should pass test", function () {
11+
analyticsExport.startExport().should.equal("test");
12+
});
13+
});

0 commit comments

Comments
 (0)