diff --git a/.github/workflows/repo-pipeline.yml b/.github/workflows/repo-pipeline.yml index d7a7c50..85f06be 100644 --- a/.github/workflows/repo-pipeline.yml +++ b/.github/workflows/repo-pipeline.yml @@ -9,142 +9,97 @@ on: type: string default: ios lint_command: - description: Command that runs lint checks + description: Optional lint command override required: false type: string default: "" build_command: - description: Command that builds the project + description: Optional build command override required: false type: string default: "" test_command: - description: Command that executes tests + description: Optional test command override required: false type: string default: "" jobs: - ci-ios: + ci: name: ci - if: ${{ inputs.repo_type == 'ios' }} - runs-on: macos-15 + runs-on: ${{ inputs.repo_type == 'ios' && 'macos-15' || 'ubuntu-latest' }} steps: - name: Checkout caller repository uses: actions/checkout@v4 - - name: Resolve commands - id: resolve + - name: Lint shell: bash run: | set -euo pipefail - lint="${{ inputs.lint_command }}" - build="${{ inputs.build_command }}" - test="${{ inputs.test_command }}" - if [ -z "$lint" ]; then - lint="if which swiftlint > /dev/null; then swiftlint --strict; else brew install swiftlint && swiftlint --strict; fi" + CMD='${{ inputs.lint_command }}' + if [ -z "$CMD" ]; then + case '${{ inputs.repo_type }}' in + ios) + CMD="if which swiftlint > /dev/null; then swiftlint --strict; else brew install swiftlint && swiftlint --strict; fi" + ;; + node) + CMD="npm run lint --if-present" + ;; + python) + CMD="python -m pip install -U pip && pip install ruff && ruff check ." + ;; + *) + CMD="echo 'No lint command configured for custom repo_type'" + ;; + esac fi - if [ -z "$build" ]; then - build="xcodebuild build -project CamperLogBook.xcodeproj -scheme CamperLogBook -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' CODE_SIGNING_ALLOWED=NO" - fi - if [ -z "$test" ]; then - test="xcodebuild test -project CamperLogBook.xcodeproj -scheme CamperLogBook -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' CODE_SIGNING_ALLOWED=NO" - fi - { - echo "lint<> "$GITHUB_OUTPUT" - - - name: Lint - shell: bash - run: ${{ steps.resolve.outputs.lint }} + eval "$CMD" - name: Build - shell: bash - run: ${{ steps.resolve.outputs.build }} - - - name: Test - shell: bash - run: ${{ steps.resolve.outputs.test }} - - ci-generic: - name: ci - if: ${{ inputs.repo_type != 'ios' }} - runs-on: ubuntu-latest - steps: - - name: Checkout caller repository - uses: actions/checkout@v4 - - - name: Resolve commands - id: resolve shell: bash run: | set -euo pipefail - repo_type="${{ inputs.repo_type }}" - lint="${{ inputs.lint_command }}" - build="${{ inputs.build_command }}" - test="${{ inputs.test_command }}" - - if [ -z "$lint" ]; then - case "$repo_type" in - node) lint="npm run lint --if-present" ;; - python) lint="python -m pip install -U pip && pip install ruff && ruff check ." ;; - custom) lint="" ;; - *) lint="" ;; + CMD='${{ inputs.build_command }}' + if [ -z "$CMD" ]; then + case '${{ inputs.repo_type }}' in + ios) + CMD="xcodebuild build -project CamperLogBook.xcodeproj -scheme CamperLogBook -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' CODE_SIGNING_ALLOWED=NO" + ;; + node) + CMD="npm run build --if-present" + ;; + python) + CMD="echo 'No build step for python default'" + ;; + *) + CMD="echo 'No build command configured for custom repo_type'" + ;; esac fi - - if [ -z "$build" ]; then - case "$repo_type" in - node) build="npm run build --if-present" ;; - python) build="" ;; - custom) build="" ;; - *) build="" ;; - esac - fi - - if [ -z "$test" ]; then - case "$repo_type" in - node) test="npm test --if-present" ;; - python) test="pytest -q" ;; - custom) test="" ;; - *) test="" ;; - esac - fi - - { - echo "lint<> "$GITHUB_OUTPUT" - - - name: Lint - if: ${{ steps.resolve.outputs.lint != '' }} - shell: bash - run: ${{ steps.resolve.outputs.lint }} - - - name: Build - if: ${{ steps.resolve.outputs.build != '' }} - shell: bash - run: ${{ steps.resolve.outputs.build }} + eval "$CMD" - name: Test - if: ${{ steps.resolve.outputs.test != '' }} shell: bash - run: ${{ steps.resolve.outputs.test }} + run: | + set -euo pipefail + CMD='${{ inputs.test_command }}' + if [ -z "$CMD" ]; then + case '${{ inputs.repo_type }}' in + ios) + CMD="xcodebuild test -project CamperLogBook.xcodeproj -scheme CamperLogBook -destination 'platform=iOS Simulator,name=iPhone 16,OS=latest' CODE_SIGNING_ALLOWED=NO" + ;; + node) + CMD="npm test --if-present" + ;; + python) + CMD="pytest -q" + ;; + *) + CMD="echo 'No test command configured for custom repo_type'" + ;; + esac + fi + eval "$CMD" security-scan: name: security-scan @@ -170,11 +125,12 @@ jobs: config: p/default - name: Dependency Review - if: github.event_name == 'pull_request' + if: ${{ github.event_name == 'pull_request' }} uses: actions/dependency-review-action@v4 ai-review: name: ai-review + if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest permissions: contents: read diff --git a/README.md b/README.md index 8ce928d..d2f18ea 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Use from another repository: ```yaml jobs: use-vanity-dev-engine: - uses: OliverGiertz/vanity-dev-engine/.github/workflows/repo-pipeline.yml@v1.1 + uses: OliverGiertz/vanity-dev-engine/.github/workflows/repo-pipeline.yml@v1.2 secrets: inherit with: repo_type: ios