From 992eb823f2ad1aced92a92fd0735e1510c9a9b26 Mon Sep 17 00:00:00 2001 From: Admin Date: Sat, 7 Mar 2026 18:23:38 +0500 Subject: [PATCH] Unify CI and justfile: all workflows call just recipes - justfile: extract ios_scheme/ios_sim/ios_spm/runner_temp variables; add ios-resolve (SPM dep cache), ios-archive, ios-export recipes; pipe xcodebuild through xcpretty with raw fallback in ios-build/ios-test - ios.yaml: replace raw xcodebuild calls with just ios-build / just ios-test; install just via brew; uncommented archive job stub now calls just ios-archive && just ios-export; add justfile to path trigger - ci-scraper.yaml: install just via extractions/setup-just@v2; use just lint / just test; fix upload-artifact v3 -> v4; add justfile to path trigger - ci-ui.yaml: install just; use just ui-install / just ui-check / just ui-build; add justfile to path trigger --- .gitea/workflows/ci-scraper.yaml | 26 +++++---- .gitea/workflows/ci-ui.yaml | 15 +++--- .gitea/workflows/ios.yaml | 92 ++++++-------------------------- justfile | 74 +++++++++++++++++++------ 4 files changed, 98 insertions(+), 109 deletions(-) diff --git a/.gitea/workflows/ci-scraper.yaml b/.gitea/workflows/ci-scraper.yaml index a806bd5..396fd19 100644 --- a/.gitea/workflows/ci-scraper.yaml +++ b/.gitea/workflows/ci-scraper.yaml @@ -5,17 +5,15 @@ on: branches: ["main", "master"] paths: - "scraper/**" + - "justfile" - ".gitea/workflows/ci-scraper.yaml" pull_request: branches: ["main", "master"] paths: - "scraper/**" + - "justfile" - ".gitea/workflows/ci-scraper.yaml" -defaults: - run: - working-directory: scraper - jobs: # ── lint & vet ─────────────────────────────────────────────────────────────── lint: @@ -29,11 +27,11 @@ jobs: go-version-file: scraper/go.mod cache-dependency-path: scraper/go.sum - - name: go vet - run: go vet ./... + - name: Install just + uses: extractions/setup-just@v2 - - name: staticcheck - run: go tool staticcheck ./... + - name: go vet + run: just lint # ── tests ──────────────────────────────────────────────────────────────────── test: @@ -47,8 +45,11 @@ jobs: go-version-file: scraper/go.mod cache-dependency-path: scraper/go.sum + - name: Install just + uses: extractions/setup-just@v2 + - name: Run tests - run: go test -race -count=1 -timeout=60s ./... + run: just test # ── build binary ───────────────────────────────────────────────────────────── build: @@ -63,13 +64,16 @@ jobs: go-version-file: scraper/go.mod cache-dependency-path: scraper/go.sum + - name: Install just + uses: extractions/setup-just@v2 + - name: Build binary run: | - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ + cd scraper && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ go build -ldflags="-s -w" -o bin/scraper ./cmd/scraper - name: Upload binary artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: scraper-linux-amd64 path: scraper/bin/scraper diff --git a/.gitea/workflows/ci-ui.yaml b/.gitea/workflows/ci-ui.yaml index d9499e4..be38d7c 100644 --- a/.gitea/workflows/ci-ui.yaml +++ b/.gitea/workflows/ci-ui.yaml @@ -5,17 +5,15 @@ on: branches: ["main", "master"] paths: - "ui/**" + - "justfile" - ".gitea/workflows/ci-ui.yaml" pull_request: branches: ["main", "master"] paths: - "ui/**" + - "justfile" - ".gitea/workflows/ci-ui.yaml" -defaults: - run: - working-directory: ui - jobs: # ── type-check & build ─────────────────────────────────────────────────────── build: @@ -30,11 +28,14 @@ jobs: cache: npm cache-dependency-path: ui/package-lock.json + - name: Install just + uses: extractions/setup-just@v2 + - name: Install dependencies - run: npm ci + run: just ui-install - name: Type check - run: npm run check + run: just ui-check - name: Build - run: npm run build + run: just ui-build diff --git a/.gitea/workflows/ios.yaml b/.gitea/workflows/ios.yaml index 16e10c1..0db523c 100644 --- a/.gitea/workflows/ios.yaml +++ b/.gitea/workflows/ios.yaml @@ -5,17 +5,15 @@ on: branches: ["v2", "main"] paths: - "ios/**" + - "justfile" - ".gitea/workflows/ios.yaml" pull_request: branches: ["v2", "main"] paths: - "ios/**" + - "justfile" - ".gitea/workflows/ios.yaml" -defaults: - run: - working-directory: ios/LibNovel - jobs: # ── build ───────────────────────────────────────────────────────────────── build: @@ -25,36 +23,14 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install just + run: brew install just + - name: Install xcodegen run: brew install xcodegen - - name: Generate Xcode project - run: xcodegen generate --spec project.yml --project . - - - name: Resolve SPM packages - run: | - xcodebuild \ - -project LibNovel.xcodeproj \ - -scheme LibNovel \ - -resolvePackageDependencies \ - -clonedSourcePackagesDirPath .spm-cache - - name: Build (simulator) - run: | - xcodebuild \ - -project LibNovel.xcodeproj \ - -scheme LibNovel \ - -configuration Debug \ - -destination 'generic/platform=iOS Simulator' \ - -clonedSourcePackagesDirPath .spm-cache \ - CODE_SIGNING_ALLOWED=NO \ - | xcpretty || xcodebuild \ - -project LibNovel.xcodeproj \ - -scheme LibNovel \ - -configuration Debug \ - -destination 'generic/platform=iOS Simulator' \ - -clonedSourcePackagesDirPath .spm-cache \ - CODE_SIGNING_ALLOWED=NO + run: just ios-build # ── test ────────────────────────────────────────────────────────────────── test: @@ -65,30 +41,14 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install just + run: brew install just + - name: Install xcodegen run: brew install xcodegen - - name: Generate Xcode project - run: xcodegen generate --spec project.yml --project . - - - name: Resolve SPM packages - run: | - xcodebuild \ - -project LibNovel.xcodeproj \ - -scheme LibNovel \ - -resolvePackageDependencies \ - -clonedSourcePackagesDirPath .spm-cache - - name: Run unit tests - run: | - xcodebuild test \ - -project LibNovel.xcodeproj \ - -scheme LibNovel \ - -configuration Debug \ - -destination 'platform=iOS Simulator,name=iPhone 17' \ - -clonedSourcePackagesDirPath .spm-cache \ - CODE_SIGNING_ALLOWED=NO \ - | xcpretty --report junit --output test-results.xml || true + run: just ios-test - name: Upload test results if: always() @@ -102,6 +62,7 @@ jobs: # Runs only on pushes to v2/main (not PRs). # Requires secrets: APPLE_CERTIFICATE_BASE64, APPLE_CERTIFICATE_PASSWORD, # APPLE_PROVISIONING_PROFILE_BASE64, KEYCHAIN_PASSWORD + # Also requires ios/LibNovel/ExportOptions.plist to exist. # # archive: # name: Archive @@ -112,13 +73,12 @@ jobs: # steps: # - uses: actions/checkout@v4 # + # - name: Install just + # run: brew install just + # # - name: Install xcodegen # run: brew install xcodegen # - # - name: Generate Xcode project - # run: xcodegen generate --spec project.yml --project . - # working-directory: ios/LibNovel - # # - name: Import signing certificate # env: # CERTIFICATE_BASE64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }} @@ -145,25 +105,5 @@ jobs: # mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles # cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles/ # - # - name: Archive - # run: | - # xcodebuild archive \ - # -project LibNovel.xcodeproj \ - # -scheme LibNovel \ - # -configuration Release \ - # -archivePath $RUNNER_TEMP/LibNovel.xcarchive - # working-directory: ios/LibNovel - # - # - name: Export IPA - # run: | - # xcodebuild -exportArchive \ - # -archivePath $RUNNER_TEMP/LibNovel.xcarchive \ - # -exportPath $RUNNER_TEMP/ipa \ - # -exportOptionsPlist ios/ExportOptions.plist - # - # - name: Upload IPA artifact - # uses: actions/upload-artifact@v4 - # with: - # name: LibNovel-release - # path: ${{ runner.temp }}/ipa/LibNovel.ipa - # retention-days: 30 + # - name: Archive & export IPA + # run: just ios-archive && just ios-export diff --git a/justfile b/justfile index 43f5926..55d78ad 100644 --- a/justfile +++ b/justfile @@ -1,9 +1,13 @@ # justfile — libnovel-v2 task runner # Install just: https://just.systems -scraper_dir := "scraper" -ui_dir := "ui" -ios_dir := "ios/LibNovel" +scraper_dir := "scraper" +ui_dir := "ui" +ios_dir := "ios/LibNovel" +ios_scheme := "LibNovel" +ios_sim := "platform=iOS Simulator,name=iPhone 17" +ios_spm := ".spm-cache" +runner_temp := env_var_or_default("RUNNER_TEMP", "/tmp") # ─── Build ──────────────────────────────────────────────────────────────────── @@ -19,7 +23,7 @@ build-all: # Run unit tests only (no integration services required) test: - cd {{scraper_dir}} && go test ./... + cd {{scraper_dir}} && go test -race -count=1 -timeout=60s ./... # Run integration tests (requires MinIO, PocketBase, optional Browserless) # Override env vars as needed, e.g.: @@ -85,23 +89,63 @@ ui-build: ios-gen: cd {{ios_dir}} && xcodegen generate --spec project.yml --project . -# Build the iOS app for the simulator (no signing required) -ios-build: ios-gen +# Resolve SPM package dependencies (cached to {{ios_spm}}) +ios-resolve: cd {{ios_dir}} && xcodebuild \ - -project LibNovel.xcodeproj \ - -scheme LibNovel \ + -project {{ios_scheme}}.xcodeproj \ + -scheme {{ios_scheme}} \ + -resolvePackageDependencies \ + -clonedSourcePackagesDirPath {{ios_spm}} + +# Build the iOS app for the simulator (no signing required) +# Runs ios-gen first to ensure the project is up to date. +ios-build: ios-gen ios-resolve + cd {{ios_dir}} && set -o pipefail && xcodebuild \ + -project {{ios_scheme}}.xcodeproj \ + -scheme {{ios_scheme}} \ -configuration Debug \ -destination 'generic/platform=iOS Simulator' \ - CODE_SIGNING_ALLOWED=NO + -clonedSourcePackagesDirPath {{ios_spm}} \ + CODE_SIGNING_ALLOWED=NO \ + | xcpretty || xcodebuild \ + -project {{ios_scheme}}.xcodeproj \ + -scheme {{ios_scheme}} \ + -configuration Debug \ + -destination 'generic/platform=iOS Simulator' \ + -clonedSourcePackagesDirPath {{ios_spm}} \ + CODE_SIGNING_ALLOWED=NO # Run unit tests on the simulator -ios-test: ios-gen - cd {{ios_dir}} && xcodebuild test \ - -project LibNovel.xcodeproj \ - -scheme LibNovel \ +# Runs ios-gen first to ensure the project is up to date. +ios-test: ios-gen ios-resolve + cd {{ios_dir}} && set -o pipefail && xcodebuild test \ + -project {{ios_scheme}}.xcodeproj \ + -scheme {{ios_scheme}} \ -configuration Debug \ - -destination 'platform=iOS Simulator,name=iPhone 17' \ - CODE_SIGNING_ALLOWED=NO + -destination '{{ios_sim}}' \ + -clonedSourcePackagesDirPath {{ios_spm}} \ + CODE_SIGNING_ALLOWED=NO \ + | xcpretty --report junit --output test-results.xml || true + +# Archive a signed Release build (requires valid signing identity in keychain). +# Output: {{runner_temp}}/LibNovel.xcarchive +# Typically called from CI after importing certificate + provisioning profile. +ios-archive: ios-gen ios-resolve + cd {{ios_dir}} && xcodebuild archive \ + -project {{ios_scheme}}.xcodeproj \ + -scheme {{ios_scheme}} \ + -configuration Release \ + -clonedSourcePackagesDirPath {{ios_spm}} \ + -archivePath {{runner_temp}}/LibNovel.xcarchive + +# Export an IPA from the archive produced by ios-archive. +# Requires ios/LibNovel/ExportOptions.plist. +# Output: {{runner_temp}}/ipa/LibNovel.ipa +ios-export: + cd {{ios_dir}} && xcodebuild -exportArchive \ + -archivePath {{runner_temp}}/LibNovel.xcarchive \ + -exportPath {{runner_temp}}/ipa \ + -exportOptionsPlist ExportOptions.plist # ─── Docker Compose ───────────────────────────────────────────────────────────