From 6eb041cb6932360374ff4afb45f9095a3d786a23 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Tue, 30 Jan 2024 15:42:41 +0000 Subject: [PATCH] CONFIG: Update CI workflows (#149) * CONFIG: Update CI workflows * CONFIG: Update CI workflows * CONFIG: Update CI workflows * Update CodeQL Xcode version --- .github/workflows/ci-documentation.yml | 24 +++++++++ .github/workflows/ci.yml | 19 ++----- .github/workflows/codeql.yml | 28 +++++----- .github/workflows/deploy-documentation.yml | 60 ++++++++++++++++++++++ .github/workflows/integration.yml | 6 +++ .github/workflows/lint-markdown.yml | 33 ++++++++++++ .github/workflows/lint.yml | 35 ++----------- 7 files changed, 147 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/ci-documentation.yml create mode 100644 .github/workflows/deploy-documentation.yml create mode 100644 .github/workflows/lint-markdown.yml diff --git a/.github/workflows/ci-documentation.yml b/.github/workflows/ci-documentation.yml new file mode 100644 index 00000000..1485dd02 --- /dev/null +++ b/.github/workflows/ci-documentation.yml @@ -0,0 +1,24 @@ +name: Documentation CI + +on: + pull_request: + branches: + - main + workflow_dispatch: + +concurrency: + group: "ci-documentation-${{ github.head_ref || github.run_id }}" + cancel-in-progress: true + +jobs: + build-documentation: + name: Build Documentation + runs-on: ubuntu-latest + env: + SWIFTCI_DOCC: 1 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build + run: swift package generate-documentation --product TMDb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be018378..a203f315 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,15 @@ name: CI on: - push: + pull_request: branches: - main - pull_request: + push: branches: - main + paths: + - ".github/workflows/ci.yml" + - "**/*.swift" workflow_dispatch: concurrency: @@ -72,15 +75,3 @@ jobs: - name: Build for Release run: swift build -c release -Xswiftc -warnings-as-errors - - build-documentation: - name: Build Documentation - runs-on: macos-13 - env: - SWIFTCI_DOCC: 1 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Build - run: swift package generate-documentation --product TMDb diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a6394146..d38a0445 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,4 +1,4 @@ -name: "CodeQL" +name: CodeQL on: push: @@ -29,19 +29,19 @@ jobs: contents: read security-events: write steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: swift - config-file: ./.github/codeql/codeql-config.yml + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: swift + config-file: ./.github/codeql/codeql-config.yml - - name: Build - run: swift build --arch arm64 --build-tests + - name: Build + run: swift build --build-tests - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:swift" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:swift" diff --git a/.github/workflows/deploy-documentation.yml b/.github/workflows/deploy-documentation.yml new file mode 100644 index 00000000..7b5f5a9c --- /dev/null +++ b/.github/workflows/deploy-documentation.yml @@ -0,0 +1,60 @@ +name: Deploy Documentation + +on: + push: + branches: + - main + paths: + - ".github/workflows/documentation.yml" + - "**/*.swift" + - "**/*.docc/**/*.md" + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "deploy-documentation" + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-latest + container: swift:5.9.2-jammy + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Build documentation + run: | + swift package --allow-writing-to-directory docs \ + generate-documentation --target TMDb \ + --disable-indexing \ + --transform-for-static-hosting \ + --hosting-base-path TMDb \ + --output-path docs + env: + SWIFTCI_DOCC: 1 + + - name: Upload documentation + uses: actions/upload-pages-artifact@v3 + with: + path: 'docs' + + deploy: + name: Deploy + runs-on: ubuntu-latest + needs: build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }}documentation/tmdb + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index f01b58fd..081fa508 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -4,6 +4,12 @@ on: pull_request: branches: - main + push: + branches: + - main + paths: + - ".github/workflows/integration.yml" + - "**/*.swift" schedule: # Every Sunday at 12am - cron: '0 0 * * 0' diff --git a/.github/workflows/lint-markdown.yml b/.github/workflows/lint-markdown.yml new file mode 100644 index 00000000..4a1b0b65 --- /dev/null +++ b/.github/workflows/lint-markdown.yml @@ -0,0 +1,33 @@ +name: Lint Markdown + +on: + pull_request: + branches: + - main + push: + branches: + - main + paths: + - ".github/workflows/lint-markdown.yml" + - "**/*.swift" + workflow_dispatch: + +concurrency: + group: "lint-markdown-${{ github.head_ref || github.run_id }}" + cancel-in-progress: true + +jobs: + markdownlint: + name: Markdownlint + runs-on: ubuntu-latest + container: + image: docker://ghcr.io/igorshubovych/markdownlint-cli:latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Lint README + run: markdownlint "README.md" + + - name: Lint DocC files + run: markdownlint "**/*.docc/**/*.md" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1b49f706..d3ed8ae2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,12 +1,15 @@ name: Lint on: - push: + pull_request: branches: - main - pull_request: + push: branches: - main + paths: + - ".github/workflows/lint.yml" + - "**/*.swift" workflow_dispatch: concurrency: @@ -37,31 +40,3 @@ jobs: - name: SwiftFormat run: swiftformat --lint . - - markdownlint: - name: Markdownlint - runs-on: ubuntu-latest - container: - image: docker://ghcr.io/igorshubovych/markdownlint-cli:latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Lint README - run: markdownlint "README.md" - - - name: Lint DocC files - run: markdownlint "**/*.docc/**/*.md" - - # markdownlint: - # name: Markdownlint - # runs-on: ubuntu-latest - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - - # - name: Lint README - # run: docker run --rm -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "README.md" - - # - name: Lint DocC files - # run: docker run --rm -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "**/*.docc/**/*.md"