Verified Commit 7a42570b authored by Daniel Sonck's avatar Daniel Sonck
Browse files

Extract build to gitlab ci and add hasNextPage

parent faf70c19
Pipeline #427 waiting for manual action with stages
in 1 minute and 48 seconds
......@@ -2,6 +2,7 @@ stages:
- prepare
- validate
- build
- package
- deploy
- publish
- destroy
......@@ -27,7 +28,8 @@ app:build:
key: ${CI_COMMIT_REF_SLUG}-go
paths:
- .go
image: quay.io/buildah/stable:v1.16.0
- .redo
image: golang:1.15.0
needs:
- job: app:prepare
artifacts: true
......@@ -36,11 +38,15 @@ app:build:
- kubernetes
- cluster
script:
- buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- ./build-docker.sh $CI_REGISTRY_IMAGE
- wget https://github.com/apenwarr/redo/archive/redo-0.42c.tar.gz
- tar -xvf redo-0.42c.tar.gz
- (cd redo-redo-0.42c; DESTDIR= PREFIX=/usr/local ./do -j10 install)
- echo "playlist_version = \"$VERSION\" > playlist.version.auto.tfvars
after_script:
- chmod u+rwx .go -R
artifacts:
paths:
- target/output/playlist
reports:
junit: target/reports/tests.xml
cobertura: target/reports/cobertura.xml
......@@ -48,6 +54,31 @@ app:build:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "development" || $CI_COMMIT_BRANCH == "development" || $CI_COMMIT_TAG =~ /^release\//'
when: on_success
app:package:
image: quay.io/buildah/stable:v1.16.0
needs:
- job: app:prepare
artifacts: true
stage: build
tags:
- kubernetes
- cluster
before_script:
- buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- buildah from scratch > container
script:
- C=$(cat container)
- buildah copy "${C}" "${PWD}/target/output/playlist" /playlist || on_fail
- buildah config --port 2001 --entrypoint '["/playlist"]' --cmd 'start --config /config/playlist.yml' "${C}"
- buildah commit "${C}" "$CI_REGISTRY_IMAGE:$VERSION"
- buildah push "$CI_REGISTRY_IMAGE:$VERSION" "docker://$CI_REGISTRY_IMAGE:$VERSION"
after_script:
- C=$(cat container)
- buildah rm "${C}"
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "development" || $CI_COMMIT_BRANCH == "development" || $CI_COMMIT_TAG =~ /^release\//'
when: on_success
include: /infra/.gitlab-ci.yml
app:publish:dev:
......
......@@ -6,6 +6,7 @@ package resolver
import (
"context"
"fmt"
playlist2 "go.touhou.fm/radio/server/playlist/internal/playlist"
"go.touhou.fm/radio/server/playlist/internal"
"go.touhou.fm/radio/server/playlist/internal/graphql/generated"
......@@ -25,7 +26,8 @@ func (r *queryResolver) Playlist(ctx context.Context, first int, after *model.Cu
var result []model.PlaylistEdge
playlist := r.PlaylistProvider.Playlist()
count := 0
for item := playlist.Start(); item != nil && count < first; item = item.Next() {
var item *playlist2.ListItem = nil
for item = playlist.Start(); item != nil && count < first; item = item.Next() {
if count > start {
result = append(result, model.PlaylistEdge{
Cursor: model.MakeCursor("PlaylistItem:%d", count),
......@@ -41,7 +43,7 @@ func (r *queryResolver) Playlist(ctx context.Context, first int, after *model.Cu
ID: fmt.Sprintf("%d:%d", start+1, count-1),
Edges: result,
PageInfo: &model.PageInfo{
HasNextPage: false,
HasNextPage: item != nil,
StartCursor: model.MakeCursor("PlaylistItem", start+1),
EndCursor: model.MakeCursor("PlaylistItem", count-1),
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment