Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,37 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Resolve server OpenAPI ref
id: server-openapi-ref
run: |
candidate="${SERVER_OPENAPI_REF:-${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}}"
if git ls-remote --exit-code --heads https://github.com/Life-USTC/server.git "$candidate" >/dev/null 2>&1; then
echo "ref=$candidate" >> "$GITHUB_OUTPUT"
else
echo "ref=main" >> "$GITHUB_OUTPUT"
fi

- name: Checkout server OpenAPI source
uses: actions/checkout@v4
with:
repository: Life-USTC/server-nextjs
path: server-nextjs
repository: Life-USTC/server
ref: ${{ steps.server-openapi-ref.outputs.ref }}
path: server

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: OpenAPI spec is synced with server
run: make check-openapi-sync OPENAPI_SOURCE=server-nextjs/public/openapi.generated.json

- name: Build
run: make build

- name: Test
run: make test

- name: Generated files are current
run: make generate && git diff --exit-code
- name: Check generated code is up-to-date
run: |
make sync-openapi generate OPENAPI_SOURCE=server/public/openapi.generated.json
git diff --exit-code

lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION ?= dev
OPENAPI_SOURCE ?= ../server-nextjs/public/openapi.generated.json
OPENAPI_SOURCE ?= ../server/public/openapi.generated.json
LDFLAGS := -ldflags "-X github.com/Life-USTC/CLI/internal/cmd/root.version=$(VERSION)"

.PHONY: build clean test lint install generate sync-openapi check-openapi-sync
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ life-ustc me
life-ustc todo --pending
life-ustc todo create --title "Write report" --priority high
life-ustc todo done <TODO_ID>
life-ustc todo done <TODO_ID_1> <TODO_ID_2>
life-ustc homework --pending
life-ustc homework create <SECTION_ID> --title "Problem Set 1"
life-ustc homework create
life-ustc homework done <HOMEWORK_ID>
life-ustc homework done <HOMEWORK_ID_1> <HOMEWORK_ID_2>
life-ustc upload file ./report.pdf
life-ustc upload download <ID> -o report.pdf
life-ustc calendar get
life-ustc calendar set <SECTION_ID_1> <SECTION_ID_2>
life-ustc calendar import-codes <CODE_1> <CODE_2>

# Browse (no auth required unless noted)
# In a terminal, bare course/section/teacher list commands open an interactive TUI.
Expand Down Expand Up @@ -81,6 +84,7 @@ life-ustc school sync
# Community features
life-ustc comment list --target-type section --target-id <ID>
life-ustc comment create --target-type section --target-id <ID> --body "Great class!"
life-ustc comment delete <COMMENT_ID_1> <COMMENT_ID_2>
life-ustc description get --target-type course --target-id <ID>
life-ustc description set --target-type course --target-id <ID> --content "Good for freshmen."

Expand Down
Loading
Loading