Skip to content

Commit

Permalink
Merge pull request #21 from tresabhi/1.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tresabhi authored Jul 14, 2023
2 parents 8a0afee + 18a3e30 commit 31f6123
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 43 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/cd-asia-ratings-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CD North America Ratings Latest

on:
schedule:
- cron: '0 0 * * *'

jobs:
host:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Yarn
run: npm install --location=global yarn

- name: Use node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn

- name: Generate leaderboard
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia --latest
34 changes: 34 additions & 0 deletions .github/workflows/cd-asia-ratings-leaderboards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CD North America Ratings Leaderboards

on:
schedule:
- cron: '0 17 * * *'

jobs:
host:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Yarn
run: npm install --location=global yarn

- name: Use node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn

- name: Generate leaderboard
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia
8 changes: 2 additions & 6 deletions .github/workflows/cd-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

strategy:
matrix:
node-version: [18.x]

steps:
- name: Get code
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 18
cache: 'npm'

- name: Install Yarn
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/cd-eu-ratings-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CD North America Ratings Latest

on:
schedule:
- cron: '0 0 * * *'

jobs:
host:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Yarn
run: npm install --location=global yarn

- name: Use node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn

- name: Generate leaderboard
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu --latest
34 changes: 34 additions & 0 deletions .github/workflows/cd-eu-ratings-leaderboards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CD North America Ratings Leaderboards

on:
schedule:
- cron: '0 23 * * *'

jobs:
host:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Yarn
run: npm install --location=global yarn

- name: Use node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn

- name: Generate leaderboard
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=eu
5 changes: 1 addition & 4 deletions .github/workflows/cd-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ concurrency:
jobs:
host:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]

steps:
- name: Use node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
node-version: 18

- name: Download release assets
run: |
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/cd-na-ratings-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CD North America Ratings Latest

on:
schedule:
- cron: '0 0 * * *'

jobs:
host:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Yarn
run: npm install --location=global yarn

- name: Use node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn

- name: Generate leaderboard
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na --latest
34 changes: 34 additions & 0 deletions .github/workflows/cd-na-ratings-leaderboards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CD North America Ratings Leaderboards

on:
schedule:
- cron: '0 5 * * *'

jobs:
host:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install Yarn
run: npm install --location=global yarn

- name: Use node_modules cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
run: yarn

- name: Generate leaderboard
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=na
21 changes: 0 additions & 21 deletions .github/workflows/cd-ratings-leaderboard-na.yml

This file was deleted.

6 changes: 1 addition & 5 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ jobs:
name: Build
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 18
cache: 'npm'

- name: Install Yarn
Expand Down
10 changes: 10 additions & 0 deletions docs/changelogs/1.10.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Blitzkrieg 1.10.2

The experiment in Blitzkrieg `1.10.1` was a bit of a failure so here are a few changes.

## Fixes

- North American leaderboards are now saved in the `na` directory instead of `asia`
- Dependencies are now installed before the script is ran
- Added leaderboards for all regions
- All regions now have their own separate cron timings
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blitzkrieg",
"version": "1.10.0",
"version": "1.10.2",
"description": "",
"main": "src/server.ts",
"type": "module",
Expand Down
19 changes: 13 additions & 6 deletions scripts/generateRatingsLeaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import { argv, env } from 'process';
import commitMultipleFiles from './commitMultipleFiles.js';

/*
For Central North American Time (UTC-5), use 0 5 * * *.
For Central European Time (UTC+1), use 0 23 * * *.
For Central Asia Standard Time (UTC+7), use 0 17 * * *.
*/
* Central North American Time (UTC-5): use 0 5 * * *.
* Central European Time (UTC+1): use 0 23 * * *.
* Central Asia Standard Time (UTC+7): use 0 17 * * *.
*
* :region/ratings/:season/info.json: season info like rewards, start & end time, etc.
* :region/ratings/:season/latest.json: the absolute latest leaderboard recorded at UTC+0 midnight
* :region/ratings/:season/leaderboards/:time.json: collection of all recorded leaderboards at local midnights
*/

const publish = argv.includes('--publish');
const latest = argv.includes('--latest');
const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1];

if (!server) throw new Error('Region parameter not specified');
Expand Down Expand Up @@ -96,8 +101,10 @@ if (publish) {
const time = Math.round(Date.now() / 1000);
const normalizedServer = server === 'na' ? 'com' : server;

const infoPath = `${normalizedServer}/ratings/seasons/${info.current_season}.json`;
const leaderboardPath = `${normalizedServer}/ratings/leaderboards/${info.current_season}/${time}.json`;
const infoPath = `${normalizedServer}/ratings/${info.current_season}/info.json`;
const leaderboardPath = `${normalizedServer}/ratings/${info.current_season}/${
latest ? 'latest.json' : `leaderboards/${time}.json`
}`;
const infoJSON = JSON.stringify(info);

console.log(`Publishing to season ${info.current_season}...`);
Expand Down

0 comments on commit 31f6123

Please sign in to comment.