Skip to content

Commit

Permalink
Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
katydecorah committed Jun 18, 2024
1 parent 967cc23 commit 4a14290
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/scheduled-advanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ jobs:
case $MONTH in
03)
echo "POST_TITLE=$(($YEAR - 1))/${YEAR} Winter" >> $GITHUB_ENV
echo "START_DATE=$(($YEAR - 1))-12-20" >> $GITHUB_ENV
echo "START_DATE=$(($YEAR - 1))-12-21" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-03-20" >> $GITHUB_ENV
;;
06)
echo "POST_TITLE=${YEAR} Spring" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-03-20" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-03-21" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-06-20" >> $GITHUB_ENV
;;
09)
echo "POST_TITLE=${YEAR} Summer" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-06-20" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-06-21" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-09-20" >> $GITHUB_ENV
;;
12)
echo "POST_TITLE=${YEAR} Fall" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-09-20" >> $GITHUB_ENV
echo "START_DATE=${YEAR}-09-21" >> $GITHUB_ENV
echo "END_DATE=${YEAR}-12-20" >> $GITHUB_ENV
;;
esac
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ inputs:
description: "Allow specific tags to be passed through. Separate each tag with a comma."

start-date:
description: "The start date for the post. The format is `YYYY-MM-DD`."
description: "The start date for the post. The format is `YYYY-MM-DD`. This can be set as an action input or workflow input."

end-date:
description: "The end date for the post. The format is `YYYY-MM-DD`."
description: "The end date for the post. The format is `YYYY-MM-DD`. This can be set as an action input or workflow input."

post-title:
description: "The title of the post."
description: "The title of the post. This can be set as an action input or workflow input."
249 changes: 249 additions & 0 deletions src/__tests__/__snapshots__/action.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,255 @@ The books I read, playlist I made, and bookmarks I saved during 2021 Summer.
]
`;

exports[`action works, action inputs 1`] = `
[
"notes/_posts/2021-09-20-2021-summer.md",
"---
title: 2021 Summer
image: 2021-summer.png
books:
- title: How to Talk So Little Kids Will Listen
authors: Joanna Faber, Julie King
url: >-
https://books.google.com/books/about/How_to_Talk_So_Little_Kids_Will_Listen.html?hl=&id=6WfUDQAAQBAJ
isbn: '9781501131653'
- title: Between the World and Me
authors: Ta-Nehisi Coates
url: https://play.google.com/store/books/details?id=TV05BgAAQBAJ
isbn: '9780679645986'
tags:
- recommend
- title: The Power of Ritual
authors: Casper ter Kuile
url: https://play.google.com/store/books/details?id=il6xDwAAQBAJ
isbn: '9780062882066'
- title: Tell the Machine Goodnight
authors: Katie Williams
url: >-
https://books.google.com/books/about/Tell_the_Machine_Goodnight.html?hl=&id=Tq6ZDwAAQBAJ
isbn: '9780525533139'
tags:
- recommend
- title: Yearbook
authors: Seth Rogen
url: https://books.google.com/books/about/Yearbook.html?hl=&id=t-0qwwEACAAJ
isbn: '9780751575774'
- title: All Adults Here
authors: Emma Straub
url: >-
https://books.google.com/books/about/All_Adults_Here.html?hl=&id=SQcmEAAAQBAJ
isbn: '9781594634703'
- title: The Wedding Date
authors: Jasmine Guillory
url: >-
https://books.google.com/books/about/The_Wedding_Date.html?hl=&id=ugGWDwAAQBAJ
isbn: '9780593098394'
- title: The Lamplighters
authors: Emma Stonex
url: https://play.google.com/store/books/details?id=FE32DwAAQBAJ
isbn: '9781984882165'
- title: Crying in H Mart
authors: Michelle Zauner
url: https://play.google.com/store/books/details?id=kRjzDwAAQBAJ
isbn: '9780525657750'
tags:
- recommend
- title: A Thousand Ships
authors: Natalie Haynes
url: https://play.google.com/store/books/details?id=mrHmDwAAQBAJ
isbn: '9780063065413'
tags:
- recommend
- title: The Divines
authors: Ellie Eaton
url: https://play.google.com/store/books/details?id=U2XbDwAAQBAJ
isbn: '9780063012219'
- title: Conversations with Friends
authors: Sally Rooney
url: >-
https://books.google.com/books/about/Conversations_with_Friends.html?hl=&id=4ZQnDwAAQBAJ
isbn: '9780451499059'
- title: 'The Five Wounds: A Novel'
authors: Kirstin Valdez Quade
url: https://play.google.com/store/books/details?id=QjXtDwAAQBAJ
isbn: '9780393242843'
tags:
- recommend
- title: The Secret Lives of Church Ladies
authors: Deesha Philyaw
url: >-
https://books.google.com/books/about/The_Secret_Lives_of_Church_Ladies.html?hl=&id=RalczQEACAAJ
isbn: '9781949199734'
tags:
- recommend
- title: Mexican Gothic
authors: Silvia Moreno-Garcia
url: https://play.google.com/store/books/details?id=ksKyDwAAQBAJ
isbn: '9780525620792'
tags:
- recommend
- title: Exciting Times
authors: Naoise Dolan
url: https://play.google.com/store/books/details?id=aa6sDwAAQBAJ
isbn: '9780062968777'
- title: The Argonauts
authors: Maggie Nelson
url: https://play.google.com/store/books/details?id=F4QkBQAAQBAJ
isbn: '9781555973407'
bookmarks:
- title: Quinoa Salad With Chicken, Almonds and Avocado Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1019495-quinoa-salad-with-chicken-almonds-and-avocado
- title: Mahi ba Somagh (Sumac Roasted Fish) Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1022268-mahi-ba-somagh-sumac-roasted-fish
- title: Rice Krispies Treats With Chocolate and Pretzels Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1019978-rice-krispies-treats-with-chocolate-and-pretzels
- title: Grilled Za’atar Chicken With Garlic Yogurt and Cilantro Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1022300-grilled-zaatar-chicken-with-garlic-yogurt-and-cilantro
- title: Crispy Baked Fish With Tartar Sauce Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1022325-crispy-baked-fish-with-tartar-sauce
- title: Kimchi Tuna Salad Recipe
site: NYT Cooking
url: https://cooking.nytimes.com/recipes/1022166-kimchi-tuna-salad
- title: No-Bake Chocolate Mousse Bars Recipe
site: NYT Cooking
url: https://cooking.nytimes.com/recipes/1019316-no-bake-chocolate-mousse-bars
- title: Grilled Chicken With Parsley-Olive Sauce Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1022335-grilled-chicken-with-parsley-olive-sauce
- title: Cherry-Almond Granola Crisp Recipe
site: NYT Cooking
url: https://cooking.nytimes.com/recipes/1021317-cherry-almond-granola-crisp
- title: Grilled Baby Back Ribs Recipe
site: NYT Cooking
url: https://cooking.nytimes.com/recipes/1017535-grilled-baby-back-ribs
- title: Todd Richards’s Fried Catfish With Hot Sauce Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1019524-todd-richardss-fried-catfish-with-hot-sauce
- title: Affogato Recipe
site: NYT Cooking
url: https://cooking.nytimes.com/recipes/1022454-affogato
- title: Sweet or Salty Lemonade Recipe
site: NYT Cooking
url: https://cooking.nytimes.com/recipes/8703-sweet-or-salty-lemonade
- title: Plum and Raspberry Cornmeal Crisp Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1022304-plum-and-raspberry-cornmeal-crisp
- title: Coffee-Praline Crunch Ice Cream Cake Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1022469-coffee-praline-crunch-ice-cream-cake
- title: Everything-Bagel Smoked Salmon Dip Recipe
site: NYT Cooking
url: >-
https://cooking.nytimes.com/recipes/1022447-everything-bagel-smoked-salmon-dip
playlist: 2021 Summer
spotify: https://open.spotify.com/playlist/5CWFqwcSoRK7AFfWH4nJyL
tracks:
- track: Kill Me
artist: Indigo De Souza
album: Kill Me
- track: In Your Eyes (Reflection)
artist: Anjimile, Jay Som
album: Reunion
- track: Floating
artist: Lealani
album: Fantastic Planet
- track: Creature of Mine
artist: Billie Marten
album: Flora Fauna
- track: Take Care of Yourself
artist: The Childlike Empress
album: Take Care of Yourself
- track: Turned Out I Was Everyone
artist: SASAMI
album: SASAMI
- track: Schatze
artist: Ohtis, Stef Chura
album: Schatze b/w Failure
- track: Lake Song
artist: Deeper
album: Auto-Pain
- track: Lavender
artist: Biig Piig
album: Lavender
- track: Holy Holy - Demo
artist: Wye Oak
album: Holy Holy (Demo)
---
The books I read, playlist I made, and bookmarks I saved during 2021 Summer.
## Books
- [How to Talk So Little Kids Will Listen](https://books.google.com/books/about/How_to_Talk_So_Little_Kids_Will_Listen.html?hl=&id=6WfUDQAAQBAJ) - Joanna Faber, Julie King
- [Between the World and Me](https://play.google.com/store/books/details?id=TV05BgAAQBAJ) - Ta-Nehisi Coates (recommend)
- [The Power of Ritual](https://play.google.com/store/books/details?id=il6xDwAAQBAJ) - Casper ter Kuile
- [Tell the Machine Goodnight](https://books.google.com/books/about/Tell_the_Machine_Goodnight.html?hl=&id=Tq6ZDwAAQBAJ) - Katie Williams (recommend)
- [Yearbook](https://books.google.com/books/about/Yearbook.html?hl=&id=t-0qwwEACAAJ) - Seth Rogen
- [All Adults Here](https://books.google.com/books/about/All_Adults_Here.html?hl=&id=SQcmEAAAQBAJ) - Emma Straub
- [The Wedding Date](https://books.google.com/books/about/The_Wedding_Date.html?hl=&id=ugGWDwAAQBAJ) - Jasmine Guillory
- [The Lamplighters](https://play.google.com/store/books/details?id=FE32DwAAQBAJ) - Emma Stonex
- [Crying in H Mart](https://play.google.com/store/books/details?id=kRjzDwAAQBAJ) - Michelle Zauner (recommend)
- [A Thousand Ships](https://play.google.com/store/books/details?id=mrHmDwAAQBAJ) - Natalie Haynes (recommend)
- [The Divines](https://play.google.com/store/books/details?id=U2XbDwAAQBAJ) - Ellie Eaton
- [Conversations with Friends](https://books.google.com/books/about/Conversations_with_Friends.html?hl=&id=4ZQnDwAAQBAJ) - Sally Rooney
- [The Five Wounds: A Novel](https://play.google.com/store/books/details?id=QjXtDwAAQBAJ) - Kirstin Valdez Quade (recommend)
- [The Secret Lives of Church Ladies](https://books.google.com/books/about/The_Secret_Lives_of_Church_Ladies.html?hl=&id=RalczQEACAAJ) - Deesha Philyaw (recommend)
- [Mexican Gothic](https://play.google.com/store/books/details?id=ksKyDwAAQBAJ) - Silvia Moreno-Garcia (recommend)
- [Exciting Times](https://play.google.com/store/books/details?id=aa6sDwAAQBAJ) - Naoise Dolan
- [The Argonauts](https://play.google.com/store/books/details?id=F4QkBQAAQBAJ) - Maggie Nelson
## Playlist
- Kill Me - Indigo De Souza
- In Your Eyes (Reflection) - Anjimile, Jay Som
- Floating - Lealani
- Creature of Mine - Billie Marten
- Take Care of Yourself - The Childlike Empress
- Turned Out I Was Everyone - SASAMI
- Schatze - Ohtis, Stef Chura
- Lake Song - Deeper
- Lavender - Biig Piig
- Holy Holy - Demo - Wye Oak
## Bookmarks
- [Quinoa Salad With Chicken, Almonds and Avocado Recipe](https://cooking.nytimes.com/recipes/1019495-quinoa-salad-with-chicken-almonds-and-avocado) - NYT Cooking
- [Mahi ba Somagh (Sumac Roasted Fish) Recipe](https://cooking.nytimes.com/recipes/1022268-mahi-ba-somagh-sumac-roasted-fish) - NYT Cooking
- [Rice Krispies Treats With Chocolate and Pretzels Recipe](https://cooking.nytimes.com/recipes/1019978-rice-krispies-treats-with-chocolate-and-pretzels) - NYT Cooking
- [Grilled Za’atar Chicken With Garlic Yogurt and Cilantro Recipe](https://cooking.nytimes.com/recipes/1022300-grilled-zaatar-chicken-with-garlic-yogurt-and-cilantro) - NYT Cooking
- [Crispy Baked Fish With Tartar Sauce Recipe](https://cooking.nytimes.com/recipes/1022325-crispy-baked-fish-with-tartar-sauce) - NYT Cooking
- [Kimchi Tuna Salad Recipe](https://cooking.nytimes.com/recipes/1022166-kimchi-tuna-salad) - NYT Cooking
- [No-Bake Chocolate Mousse Bars Recipe](https://cooking.nytimes.com/recipes/1019316-no-bake-chocolate-mousse-bars) - NYT Cooking
- [Grilled Chicken With Parsley-Olive Sauce Recipe](https://cooking.nytimes.com/recipes/1022335-grilled-chicken-with-parsley-olive-sauce) - NYT Cooking
- [Cherry-Almond Granola Crisp Recipe](https://cooking.nytimes.com/recipes/1021317-cherry-almond-granola-crisp) - NYT Cooking
- [Grilled Baby Back Ribs Recipe](https://cooking.nytimes.com/recipes/1017535-grilled-baby-back-ribs) - NYT Cooking
- [Todd Richards’s Fried Catfish With Hot Sauce Recipe](https://cooking.nytimes.com/recipes/1019524-todd-richardss-fried-catfish-with-hot-sauce) - NYT Cooking
- [Affogato Recipe](https://cooking.nytimes.com/recipes/1022454-affogato) - NYT Cooking
- [Sweet or Salty Lemonade Recipe](https://cooking.nytimes.com/recipes/8703-sweet-or-salty-lemonade) - NYT Cooking
- [Plum and Raspberry Cornmeal Crisp Recipe](https://cooking.nytimes.com/recipes/1022304-plum-and-raspberry-cornmeal-crisp) - NYT Cooking
- [Coffee-Praline Crunch Ice Cream Cake Recipe](https://cooking.nytimes.com/recipes/1022469-coffee-praline-crunch-ice-cream-cake) - NYT Cooking
- [Everything-Bagel Smoked Salmon Dip Recipe](https://cooking.nytimes.com/recipes/1022447-everything-bagel-smoked-salmon-dip) - NYT Cooking
",
]
`;

exports[`action works, custom template 1`] = `
[
"notes/_posts/2021-09-20-2021-summer.md",
Expand Down
59 changes: 49 additions & 10 deletions src/__tests__/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ import * as github from "@actions/github";

jest.mock("@actions/core");

const defaultInputs = {
"github-username": "katydecorah",
"github-repository": "archive",
"posts-directory": "notes/_posts/",
"post-template": "",
"source-books": "books|_data/read.json",
"source-bookmarks": "bookmarks|_data/bookmarks.json",
"source-playlist": "_data/playlists.yml",
"book-tags": "recommend, skip",
};
let defaultInputs;

beforeEach(() => {
defaultInputs = {
"github-username": "katydecorah",
"github-repository": "archive",
"posts-directory": "notes/_posts/",
"post-template": "",
"source-books": "books|_data/read.json",
"source-bookmarks": "bookmarks|_data/bookmarks.json",
"source-playlist": "_data/playlists.yml",
"book-tags": "recommend, skip",
};
Object.defineProperty(github, "context", {
value: {
payload: {
Expand All @@ -35,6 +36,7 @@ beforeEach(() => {
},
},
});

jest
.spyOn(core, "getInput")
.mockImplementation((name) => defaultInputs[name] || undefined);
Expand Down Expand Up @@ -183,6 +185,43 @@ describe("action", () => {
expect(setFailed).not.toHaveBeenCalled();
expect(writeSpy.mock.calls[0]).toMatchSnapshot();
});

test("works, action inputs", async () => {
Object.defineProperty(github, "context", {
value: {
payload: {},
},
});

defaultInputs["post-title"] = "2021 Summer";
defaultInputs["start-date"] = "2021-06-21";
defaultInputs["end-date"] = "2021-09-20";
const warningSpy = jest.spyOn(core, "warning").mockImplementation();

const getJsonFileSpy = jest
.spyOn(GetJsonFile, "getJsonFile")
.mockReturnValueOnce(books)
.mockReturnValueOnce(recipes);
const getDataFileSpy = jest
.spyOn(GetDataFile, "getDataFile")
.mockReturnValueOnce(playlists);
const formatBooksSpy = jest.spyOn(Format, "formatBooks");
const formatBookmarksSpy = jest.spyOn(Format, "formatBookmarks");
const formatPlaylistsSpy = jest.spyOn(Format, "formatPlaylist");
const writeSpy = jest.spyOn(promises, "writeFile").mockImplementation();
await action();

expect(warningSpy).not.toHaveBeenCalled();
expect(getJsonFileSpy).toHaveBeenNthCalledWith(1, "_data/read.json");
expect(getJsonFileSpy).toHaveNthReturnedWith(1, books);
expect(getJsonFileSpy).toHaveBeenNthCalledWith(2, "_data/bookmarks.json");
expect(getDataFileSpy).toHaveBeenNthCalledWith(1, "_data/playlists.yml");
expect(setFailed).not.toHaveBeenCalled();
expect(formatBooksSpy).toHaveBeenCalled();
expect(formatBookmarksSpy).toHaveBeenCalled();
expect(formatPlaylistsSpy).toHaveBeenCalled();
expect(writeSpy.mock.calls[0]).toMatchSnapshot();
});
});

describe("validateInputs", () => {
Expand Down

0 comments on commit 4a14290

Please sign in to comment.