Skip to content

Commit

Permalink
Merge pull request #149 from claabs/develop
Browse files Browse the repository at this point in the history
v4 release
  • Loading branch information
claabs authored Oct 2, 2021
2 parents 9a90de5 + 619316f commit 3e82141
Show file tree
Hide file tree
Showing 70 changed files with 6,712 additions and 11,240 deletions.
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
!src
!package*.json
!tsconfig.json
!entrypoint.sh

src/site/public/node_modules
!entrypoint.sh
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
extends: [
'airbnb-base',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
'plugin:jest/recommended',
],
Expand All @@ -17,7 +16,10 @@ module.exports = {
},
plugins: ['@typescript-eslint', 'jest'],
rules: {
'import/extensions': 0
'import/extensions': 0,
'import/prefer-default-export': 0,
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
},
settings: {
'import/extensions': ['.js', '.ts',],
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report-captcha-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ assignees: ''
<!-- Before filing a bug, make sure you're using the latest Docker image, or check the commit history to see if your issue has already been fixed -->

**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->

**Screenshots or Logs**
Add screenshots or logs from the container and your browser's dev tools to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share.
<!-- Add screenshots or logs from the container and your browser's dev tools to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share. -->

**Configuration (please complete the following information):**
- Browser:
- Hosting solution [e.g. reverse proxy, HTTPS/HTTP, caching, localhost]:

**Additional context**
Add any other context about the problem here.
<!-- Add any other context about the problem here. -->
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/bug-report-item-redeem.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report (item redeem)
about: An issue related to redeeming a game, or finding available free games
name: Bug report (other)
about: An issue related to redeeming games, finding free games, logging in, notifications, or config validation
title: ''
labels: bug
assignees: ''
Expand All @@ -10,10 +10,10 @@ assignees: ''
<!-- Before filing a bug, make sure you're using the latest Docker image, or check the commit history to see if your issue has already been fixed -->

**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->

**Screenshots or Logs**
Add screenshots or logs to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share.
<!-- Add screenshots or logs to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share. -->

**Additional context**
Add any other context about the problem here.
<!-- Add any other context about the problem here. -->
4 changes: 2 additions & 2 deletions .github/workflows/build-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
- name: Setup Node.js for use with actions
uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '14'

- name: NPM install
run: npm i
run: npm ci

# Runs a single command using the runners shell
- name: Build and lint
Expand Down
41 changes: 34 additions & 7 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:
- develop

jobs:
build_multi_arch_image:
Expand All @@ -14,6 +14,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set environment variables
run: echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand All @@ -29,15 +32,39 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push master
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v2
with:
target: deploy
push: true
tags: |
charlocharlie/epicgames-freegames:${{ github.sha }}
charlocharlie/epicgames-freegames:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
charlocharlie/epicgames-freegames:${{ github.sha }}
ghcr.io/claabs/epicgames-freegames-node:latest
ghcr.io/claabs/epicgames-freegames-node:${{ github.sha }}
platforms: linux/amd64,linux/arm64
build-args: |
COMMIT_SHA=${{ github.sha }}
BRANCH=${{ env.GIT_BRANCH }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Build and push dev
if: ${{ github.ref == 'refs/heads/develop' }}
uses: docker/build-push-action@v2
with:
target: deploy
push: true
tags: |
charlocharlie/epicgames-freegames:dev
ghcr.io/claabs/epicgames-freegames-node:dev
platforms: linux/amd64,linux/arm64
build-args: |
COMMIT_SHA=${{ github.sha }}
BRANCH=${{ env.GIT_BRANCH }}
27 changes: 27 additions & 0 deletions .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Typedoc to Github Pages
on:
push:
branches:
- master
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js for use with actions
uses: actions/setup-node@v2
with:
node-version: '14'

- name: NPM install
run: npm ci

# Runs a single command using the runners shell
- name: Build and lint
run: npm run docs

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
hars
docs

# Logs
logs
Expand Down Expand Up @@ -108,4 +109,10 @@ dist
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

config/*
config/*
test-cookies.json
test.html
test.png
test2.html

.idea
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14
1 change: 0 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
printWidth: 100,
singleQuote: true,
trailingComma: 'es5'
}
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"[typescript]": {
"editor.formatOnSave": false,
},
"eslint.enable": true,
"typescript.tsdk": "node_modules\\typescript\\lib",
"docker.defaultRegistryPath": "charlocharlie",
"[json]": {
"files.insertFinalNewline": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.workingDirectories": [
".",
"./src/site/public"
"."
]
}
50 changes: 40 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
########
# BASE
########
FROM node:12-alpine as base
FROM node:14-alpine as base

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1

WORKDIR /usr/app

Expand All @@ -12,10 +14,9 @@ FROM base as build

# Copy all source files
COPY package*.json tsconfig.json ./
COPY src/site/public/package*.json src/site/public/tsconfig.json ./src/site/public/

# Add dev deps
RUN npm ci && cd src/site/public && npm ci
RUN npm ci

# Copy source code
COPY src src
Expand All @@ -27,19 +28,29 @@ RUN npm run build
########
FROM base as deploy

VOLUME [ "/usr/app/config" ]

RUN apk add --no-cache \
# Chromium dependencies https://github.com/Zenika/alpine-chrome/blob/master/Dockerfile
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories \
&& apk add --no-cache \
libstdc++ \
chromium \
harfbuzz \
nss \
freetype \
ttf-freefont \
font-noto-emoji \
wqy-zenhei \
# App dependencies
jq \
tzdata
tzdata

ENV NODE_ENV production

# Copy package.json for version number
COPY package*.json ./
COPY src/site/public/package*.json src/site/public/tsconfig.json ./src/site/public/

RUN npm ci --only=production && cd src/site/public && npm ci --only=production
RUN npm ci --only=production

# Steal compiled code from build image
COPY --from=build /usr/app/dist ./dist
Expand All @@ -48,6 +59,25 @@ COPY entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# backwards compat (from https://success.docker.com/article/use-a-script-to-initialize-stateful-container-data)
RUN ln -s /usr/local/bin/docker-entrypoint.sh /

ARG COMMIT_SHA="" \
BRANCH=""

LABEL org.opencontainers.image.title="epicgames-freegames-node" \
org.opencontainers.image.url="https://github.com/claabs/epicgames-freegames-node" \
org.opencontainers.image.description="Automatically redeem free games promotions on the Epic Games store" \
org.opencontainers.image.name="epicgames-freegames-node" \
org.opencontainers.image.revision=${COMMIT_SHA} \
org.opencontainers.image.ref.name=${BRANCH} \
org.opencontainers.image.base.name="node:14-alpine" \
org.opencontainers.image.version="latest"

ENV NODE_ENV=production \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
COMMIT_SHA=${COMMIT_SHA} \
BRANCH=${BRANCH}

EXPOSE 3000

VOLUME [ "/usr/app/config" ]

ENTRYPOINT ["docker-entrypoint.sh"]
28 changes: 0 additions & 28 deletions Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,3 @@ A general overview of the purchase process. See the code for specifics.
1. Call order preview with the namespaceId and offerId in the body, and the purchase token in a header
1. Remember the order preview response
1. Call confirm order with essentially the contents of order preview, and the purchase token in a header

## Testing

Assuming there will always be at least one free game offer available, test account creation can be done with the following strategy:

### New Strategy

Epic does not filter out the plus-sign suffix that many email mailboxes use to reuse emails. Because of this, we can just create accounts using the same permanent email address.

### Old Strategy

1. Have a **permanent email** on a trusted domain (e.g. gmail.com) that is used to create the account.
- Epic blocks registering accounts with temp email domains. However they don't block temp email domains on the "change email" process.
1. Create the account with a random first name, last name, username, and password.
- Random 16 character alphanumeric username should work
1. Use email APIs to verify the account.
- This may not be required for what we're testing.
1. Perform the tests using this account's credentials.

Whether the tests fail or complete, we need to tear down the account:

1. Using a temp mail service's API ([like this](https://rapidapi.com/Privatix/api/temp-mail)), create a **temp email**.
2. Begin Epic's email address change process to switch from the **permanent email** to the **temp email**.
3. Confirm the email change using the security code sent to the **permanent email**.
4. *(Optional):* Delete the account.
- Not sure if deleting the account increases or reduces the attention we will recieve.

This process lets us create a fresh account for testing, repeatedly, using the same permanent email.
Loading

0 comments on commit 3e82141

Please sign in to comment.