From 3e5ba0fff1cfdf12486b549ff0de0d507706cf91 Mon Sep 17 00:00:00 2001 From: Roman Gardukevich Date: Thu, 25 Jan 2024 13:54:51 +0200 Subject: [PATCH] Format workflow --- .github/workflows/analyze.yml | 69 +++++++++++++++++++++++++++++++++++ .github/workflows/codeql.yml | 46 ++++------------------- 2 files changed, 76 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/analyze.yml diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml new file mode 100644 index 000000000000..63e2f45dba21 --- /dev/null +++ b/.github/workflows/analyze.yml @@ -0,0 +1,69 @@ +on: + workflow_call: + inputs: + project-path: + required: true + type: string + +jobs: + analyze: + name: Analyze + runs-on: ${{ matrix.executor }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["javascript", "python", "ruby"] + executor: ["ubuntu-latest"] + include: + - language: "swift" + executor: "macos-latest" + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Allow cloning public repositories from github.com via SSH + run: | + git config --global url.https://github.com/.insteadOf git@github.com: + + - name: Inject tokens + if: matrix.language == 'swift' + run: | + echo "machine api.mapbox.com login mapbox password ${{ secrets.SDK_REGISTRY_TOKEN }}" >> ~/.netrc + chmod 0600 ~/.netrc + + echo "test_token" > ~/.mapbox + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + - name: Build Examples + if: matrix.language == 'swift' + run: set -o pipefail && xcodebuild build -project '${{ inputs.project-path }}' -scheme MapboxMaps -destination 'generic/platform=iOS Simulator'| tee xcodebuild.log | xcpretty + + - name: Archive xcodebuild.log + uses: actions/upload-artifact@v4 + if: matrix.language == 'swift' + with: + name: xcodebuild.log + path: xcodebuild.log + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 565655f61734..04649cae8daf 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,47 +2,15 @@ name: "CodeQL" on: push: - branches: [main, publisher-production, release/*, lts/*] + branches: [main, publisher-production, release/*, lts/*, feature/codeql] pull_request: - branches: [main] + # The branches below must be a subset of the branches above + branches: [main, publisher-production, release/*, lts/*] schedule: - - cron: "39 3 * * 0" + - cron: "16 20 * * 4" jobs: analyze: - name: Analyze - runs-on: macos-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: ["swift"] - - env: - SDK_REGISTRY_TOKEN: ${{ secrets.SDK_REGISTRY_TOKEN }} - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Prepare netrc - run: | - echo "machine api.mapbox.com login mapbox password $SDK_REGISTRY_TOKEN" >> ~/.netrc - chmod 0600 ~/.netrc - - name: Build - run: xcodebuild build -scheme MapboxMaps -destination 'generic/platform=iOS Simulator' - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + uses: ./.github/workflows/analyze.yml + with: + project-path: Apps/Examples/Examples.xcodeproj