Skip to content

Commit

Permalink
Add a since prop to project defs (#59)
Browse files Browse the repository at this point in the history
* Support a since key in the project definition

* Improve github actions

* Linting should check the action yml too
  • Loading branch information
gausie committed Apr 4, 2024
1 parent 2ed7066 commit fbd4009
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This workflow will do a clean install of node dependencies, build the source
# code across multiple Node.js versions, and lint the project.

name: Build & Lint

on:
Expand All @@ -9,18 +8,21 @@ on:
pull_request:
branches: [main]

env:
# Default version of Node.js for jobs
node-version: "18"

jobs:
lint:
name: Code formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- run: yarn install --frozen-lockfile
node-version: latest
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Check code formatting
run: yarn run lint
14 changes: 9 additions & 5 deletions .github/workflows/deploy_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ name: Deploy KoLmafia script

on:
push:
branches: [main]
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
name: Build and Push
steps:
- name: git-checkout
uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
cache: yarn
node-version: latest

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build script
run: yarn workspace excavator-script run build

- name: Push
uses: s0/git-publish-subdir-action@develop
env:
Expand All @@ -27,4 +31,4 @@ jobs:
FOLDER: packages/excavator-script/dist # The directory where your assets are generated
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token
MESSAGE: "Build: ({sha}) {msg}" # The commit message
SKIP_EMPTY_COMMITS: true
SKIP_EMPTY_COMMITS: true
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"build": "yarn workspace excavator-script run build",
"format": "yarn workspaces run format",
"lint": "yarn workspaces run lint"
"format": "yarn workspaces run format && yarn prettier --write .github",
"lint": "yarn workspaces run lint && yarn prettier --check .github"
}
}
4 changes: 3 additions & 1 deletion packages/excavator-script/src/excavator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getRevision } from "kolmafia";

import { projects } from "./projects";
import { Hooks } from "./type";
import { sendSpadingData } from "./utils/spading";
Expand All @@ -10,7 +12,7 @@ function tupleNotNull<A, B>(

function main(event: keyof Hooks, meta: string, page: string) {
projects
.filter(({ hooks }) => event in hooks)
.filter(({ hooks, since = 0 }) => event in hooks && since <= getRevision())
.map(({ name, hooks }) => [name, hooks[event]!(meta, page)] as const)
.filter(tupleNotNull)
.forEach(([name, data]) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/excavator-script/src/projects/monsterParts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
dartPartsToSkills,
Effect,
Familiar,
getRevision,
haveEquipped,
isWearingOutfit,
Item,
Expand Down Expand Up @@ -175,8 +174,7 @@ function spadeMonsterParts(
encounter: string,
page: string,
): MonsterPartsData[] | null {
if (getRevision() < 27884 || MONSTER_DENYLIST.includes(lastMonster()))
return null;
if (MONSTER_DENYLIST.includes(lastMonster())) return null;

const monster = toNormalisedString(lastMonster());
const monsterParts = lastMonster().parts;
Expand Down Expand Up @@ -293,4 +291,5 @@ export const MONSTER_PARTS: ExcavatorProject = {
hooks: {
COMBAT_ROUND: spadeMonsterParts,
},
since: 27884, // Monster.prototype.parts added
};
1 change: 1 addition & 0 deletions packages/excavator-script/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export type Hooks = {
export type ExcavatorProject = {
name: string;
hooks: Partial<Hooks>;
since?: number;
};

0 comments on commit fbd4009

Please sign in to comment.