Skip to content

Commit

Permalink
Schedule integration tests with GitHub action (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nstratos authored Mar 24, 2021
1 parent cd3c688 commit c7a6716
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 82 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: integration

on:
workflow_dispatch:

schedule:
- cron: "0 10 * * 6"

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.x

- name: Checkout code
uses: actions/checkout@v2

- name: Mod verify
run: go mod verify

- name: Run all tests including integration tests
run: |
cd mal
go test -v --access-token=${{ secrets.MAL_ACCESS_TOKEN }}
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
on: [push, pull_request]
name: tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
strategy:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/nstratos/go-myanimelist/mal.svg)](https://pkg.go.dev/github.com/nstratos/go-myanimelist/mal)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/nstratos/go-myanimelist)](https://goreportcard.com/report/github.com/nstratos/go-myanimelist)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nstratos_go-myanimelist&metric=alert_status)](https://sonarcloud.io/dashboard?id=nstratos_go-myanimelist)
[![Coverage Status](https://coveralls.io/repos/github/nstratos/go-myanimelist/badge.svg?branch=main)](https://coveralls.io/github/nstratos/go-myanimelist?branch=main)
[![Actions Status](https://github.com/nstratos/go-myanimelist/workflows/tests/badge.svg)](https://github.com/nstratos/go-myanimelist/actions)
[![Test Status](https://github.com/nstratos/go-myanimelist/workflows/tests/badge.svg)](https://github.com/nstratos/go-myanimelist/actions?query=workflow%3Atests)
[![Integration Status](https://github.com/nstratos/go-myanimelist/workflows/integration/badge.svg)](https://github.com/nstratos/go-myanimelist/actions?query=workflow%3Aintegration)

go-myanimelist is a Go client library for accessing the [MyAnimeList API v2](https://myanimelist.net/apiconfig/references/api/v2).

Expand Down
114 changes: 57 additions & 57 deletions mal/anime.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,103 +20,103 @@ type AnimeService struct {

// Anime represents a MyAnimeList anime.
type Anime struct {
ID int `json:"id,omitempty"`
Title string `json:"title,omitempty"`
MainPicture Picture `json:"main_picture,omitempty"`
AlternativeTitles Titles `json:"alternative_titles,omitempty"`
StartDate string `json:"start_date,omitempty"`
EndDate string `json:"end_date,omitempty"`
Synopsis string `json:"synopsis,omitempty"`
Mean float64 `json:"mean,omitempty"`
Rank int `json:"rank,omitempty"`
Popularity int `json:"popularity,omitempty"`
NumListUsers int `json:"num_list_users,omitempty"`
NumScoringUsers int `json:"num_scoring_users,omitempty"`
NSFW string `json:"nsfw,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
MediaType string `json:"media_type,omitempty"`
Status string `json:"status,omitempty"`
Genres []Genre `json:"genres,omitempty"`
MyListStatus AnimeListStatus `json:"my_list_status,omitempty"`
NumEpisodes int `json:"num_episodes,omitempty"`
StartSeason StartSeason `json:"start_season,omitempty"`
Broadcast Broadcast `json:"broadcast,omitempty"`
Source string `json:"source,omitempty"`
AverageEpisodeDuration int `json:"average_episode_duration,omitempty"`
Rating string `json:"rating,omitempty"`
Pictures []Picture `json:"pictures,omitempty"`
Background string `json:"background,omitempty"`
RelatedAnime []RelatedAnime `json:"related_anime,omitempty"`
RelatedManga []RelatedManga `json:"related_manga,omitempty"`
Recommendations []RecommendedAnime `json:"recommendations,omitempty"`
Studios []Studio `json:"studios,omitempty"`
Statistics Statistics `json:"statistics,omitempty"`
ID int `json:"id"`
Title string `json:"title"`
MainPicture Picture `json:"main_picture"`
AlternativeTitles Titles `json:"alternative_titles"`
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
Synopsis string `json:"synopsis"`
Mean float64 `json:"mean"`
Rank int `json:"rank"`
Popularity int `json:"popularity"`
NumListUsers int `json:"num_list_users"`
NumScoringUsers int `json:"num_scoring_users"`
NSFW string `json:"nsfw"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
MediaType string `json:"media_type"`
Status string `json:"status"`
Genres []Genre `json:"genres"`
MyListStatus AnimeListStatus `json:"my_list_status"`
NumEpisodes int `json:"num_episodes"`
StartSeason StartSeason `json:"start_season"`
Broadcast Broadcast `json:"broadcast"`
Source string `json:"source"`
AverageEpisodeDuration int `json:"average_episode_duration"`
Rating string `json:"rating"`
Pictures []Picture `json:"pictures"`
Background string `json:"background"`
RelatedAnime []RelatedAnime `json:"related_anime"`
RelatedManga []RelatedManga `json:"related_manga"`
Recommendations []RecommendedAnime `json:"recommendations"`
Studios []Studio `json:"studios"`
Statistics Statistics `json:"statistics"`
}

// Picture is a representative picture from the show.
type Picture struct {
Medium string `json:"medium,omitempty"`
Large string `json:"large,omitempty"`
Medium string `json:"medium"`
Large string `json:"large"`
}

// Titles of the anime in English and Japanese.
type Titles struct {
Synonyms []string `json:"synonyms,omitempty"`
En string `json:"en,omitempty"`
Ja string `json:"ja,omitempty"`
Synonyms []string `json:"synonyms"`
En string `json:"en"`
Ja string `json:"ja"`
}

// The Genre of the anime.
type Genre struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ID int `json:"id"`
Name string `json:"name"`
}

// The Studio that created the anime.
type Studio struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
ID int `json:"id"`
Name string `json:"name"`
}

// Status of the user's anime list contained in statistics.
type Status struct {
Watching string `json:"watching,omitempty"`
Completed string `json:"completed,omitempty"`
OnHold string `json:"on_hold,omitempty"`
Dropped string `json:"dropped,omitempty"`
PlanToWatch string `json:"plan_to_watch,omitempty"`
Watching string `json:"watching"`
Completed string `json:"completed"`
OnHold string `json:"on_hold"`
Dropped string `json:"dropped"`
PlanToWatch string `json:"plan_to_watch"`
}

// Statistics about the anime.
type Statistics struct {
Status Status `json:"status,omitempty"`
NumListUsers int `json:"num_list_users,omitempty"`
Status Status `json:"status"`
NumListUsers int `json:"num_list_users"`
}

// RecommendedAnime is a recommended anime.
type RecommendedAnime struct {
Node Anime `json:"node,omitempty"`
NumRecommendations int `json:"num_recommendations,omitempty"`
Node Anime `json:"node"`
NumRecommendations int `json:"num_recommendations"`
}

// RelatedAnime contains a related anime.
type RelatedAnime struct {
Node Anime `json:"node,omitempty"`
RelationType string `json:"relation_type,omitempty"`
RelationTypeFormatted string `json:"relation_type_formatted,omitempty"`
Node Anime `json:"node"`
RelationType string `json:"relation_type"`
RelationTypeFormatted string `json:"relation_type_formatted"`
}

// StartSeason is the season an anime starts.
type StartSeason struct {
Year int `json:"year,omitempty"`
Season string `json:"season,omitempty"`
Year int `json:"year"`
Season string `json:"season"`
}

// Broadcast is the day and time that the show broadcasts.
type Broadcast struct {
DayOfTheWeek string `json:"day_of_the_week,omitempty"`
StartTime string `json:"start_time,omitempty"`
DayOfTheWeek string `json:"day_of_the_week"`
StartTime string `json:"start_time"`
}

// DetailsOption is an option specific for the anime and manga details methods.
Expand Down
2 changes: 1 addition & 1 deletion mal/manga.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Author struct {

// RelatedManga shows manga related with the returned entry.
type RelatedManga struct {
Node Manga `json:"node,omitempty"`
Node Manga `json:"node"`
RelationType string `json:"relation_type"`
RelationTypeFormatted string `json:"relation_type_formatted"`
}
Expand Down
44 changes: 22 additions & 22 deletions mal/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ type UserService struct {

// User represents a MyAnimeList user.
type User struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Gender string `json:"gender,omitempty"`
Location string `json:"location,omitempty"`
Picture string `json:"picture,omitempty"`
JoinedAt time.Time `json:"joined_at,omitempty"`
AnimeStatistics AnimeStatistics `json:"anime_statistics,omitempty"`
ID int64 `json:"id"`
Name string `json:"name"`
Gender string `json:"gender"`
Location string `json:"location"`
Picture string `json:"picture"`
JoinedAt time.Time `json:"joined_at"`
AnimeStatistics AnimeStatistics `json:"anime_statistics"`
}

// AnimeStatistics about the user.
type AnimeStatistics struct {
NumItemsWatching int `json:"num_items_watching,omitempty"`
NumItemsCompleted int `json:"num_items_completed,omitempty"`
NumItemsOnHold int `json:"num_items_on_hold,omitempty"`
NumItemsDropped int `json:"num_items_dropped,omitempty"`
NumItemsPlanToWatch int `json:"num_items_plan_to_watch,omitempty"`
NumItems int `json:"num_items,omitempty"`
NumDaysWatched float64 `json:"num_days_watched,omitempty"`
NumDaysWatching float64 `json:"num_days_watching,omitempty"`
NumDaysCompleted float64 `json:"num_days_completed,omitempty"`
NumDaysOnHold float64 `json:"num_days_on_hold,omitempty"`
NumDaysDropped float64 `json:"num_days_dropped,omitempty"`
NumDays float64 `json:"num_days,omitempty"`
NumEpisodes int `json:"num_episodes,omitempty"`
NumTimesRewatched int `json:"num_times_rewatched,omitempty"`
MeanScore float64 `json:"mean_score,omitempty"`
NumItemsWatching int `json:"num_items_watching"`
NumItemsCompleted int `json:"num_items_completed"`
NumItemsOnHold int `json:"num_items_on_hold"`
NumItemsDropped int `json:"num_items_dropped"`
NumItemsPlanToWatch int `json:"num_items_plan_to_watch"`
NumItems int `json:"num_items"`
NumDaysWatched float64 `json:"num_days_watched"`
NumDaysWatching float64 `json:"num_days_watching"`
NumDaysCompleted float64 `json:"num_days_completed"`
NumDaysOnHold float64 `json:"num_days_on_hold"`
NumDaysDropped float64 `json:"num_days_dropped"`
NumDays float64 `json:"num_days"`
NumEpisodes int `json:"num_episodes"`
NumTimesRewatched int `json:"num_times_rewatched"`
MeanScore float64 `json:"mean_score"`
}

// MyInfoOption are options specific to the User.MyInfo method.
Expand Down

0 comments on commit c7a6716

Please sign in to comment.