From 0f30a63e61b9c6253df01f156b432112dfc59a87 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Sun, 26 May 2024 14:41:23 -0400 Subject: [PATCH] chore: update global workflows (#14) Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- .codeql-prebuild-cpp-Linux.sh | 28 ++++++++++++ .codeql-prebuild-cpp-Windows.sh | 21 +++++++++ .codeql-prebuild-cpp-macOS.sh | 16 +++++++ .github/workflows/auto-create-pr.yml | 35 --------------- .github/workflows/automerge.yml | 64 --------------------------- .github/workflows/ci.yml | 48 ++++++++++---------- .github/workflows/codeql.yml | 66 ++++++++++++++++++++++------ .github/workflows/cpp-lint.yml | 6 +-- .github/workflows/python-flake8.yml | 4 +- .github/workflows/yaml-lint.yml | 4 +- 10 files changed, 148 insertions(+), 144 deletions(-) create mode 100644 .codeql-prebuild-cpp-Linux.sh create mode 100644 .codeql-prebuild-cpp-Windows.sh create mode 100644 .codeql-prebuild-cpp-macOS.sh delete mode 100644 .github/workflows/auto-create-pr.yml delete mode 100644 .github/workflows/automerge.yml diff --git a/.codeql-prebuild-cpp-Linux.sh b/.codeql-prebuild-cpp-Linux.sh new file mode 100644 index 0000000..800a89e --- /dev/null +++ b/.codeql-prebuild-cpp-Linux.sh @@ -0,0 +1,28 @@ +# install dependencies for C++ analysis +set -e + +sudo apt-get update -y + +# allow newer gcc +sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + +sudo apt-get install -y \ + build-essential \ + cmake \ + libayatana-appindicator3-dev \ + libglib2.0-dev \ + libnotify-dev \ + ninja-build + +# clean apt cache +sudo apt-get clean +sudo rm -rf /var/lib/apt/lists/* + +# build +mkdir -p build +cd build || exit 1 +cmake -G Ninja .. +ninja + +# skip autobuild +echo "skip_autobuild=true" >> "$GITHUB_OUTPUT" diff --git a/.codeql-prebuild-cpp-Windows.sh b/.codeql-prebuild-cpp-Windows.sh new file mode 100644 index 0000000..d32da0b --- /dev/null +++ b/.codeql-prebuild-cpp-Windows.sh @@ -0,0 +1,21 @@ +# install dependencies for C++ analysis +set -e + +# update pacman +pacman --noconfirm -Suy + +# install dependencies +pacman --noconfirm -S \ + mingw-w64-ucrt-x86_64-binutils \ + mingw-w64-ucrt-x86_64-cmake \ + mingw-w64-ucrt-x86_64-ninja \ + mingw-w64-ucrt-x86_64-toolchain + +# build +mkdir -p build +cd build || exit 1 +cmake -G Ninja .. +ninja + +# skip autobuild +echo "skip_autobuild=true" >> "$GITHUB_OUTPUT" diff --git a/.codeql-prebuild-cpp-macOS.sh b/.codeql-prebuild-cpp-macOS.sh new file mode 100644 index 0000000..0f1aeeb --- /dev/null +++ b/.codeql-prebuild-cpp-macOS.sh @@ -0,0 +1,16 @@ +# install dependencies for C++ analysis +set -e + +# install dependencies +brew install \ + cmake \ + ninja + +# build +mkdir -p build +cd build || exit 1 +cmake -G Ninja .. +ninja + +# skip autobuild +echo "skip_autobuild=true" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/auto-create-pr.yml b/.github/workflows/auto-create-pr.yml deleted file mode 100644 index 13705dd..0000000 --- a/.github/workflows/auto-create-pr.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -# This action is centrally managed in https://github.com//.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in -# the above-mentioned repo. - -# This workflow creates a PR automatically when anything is merged/pushed into the `nightly` branch. The PR is created -# against the `master` (default) branch. - -name: Auto create PR - -on: - push: - branches: - - 'nightly' - -jobs: - create_pr: - if: startsWith(github.repository, 'LizardByte/') - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Create Pull Request - uses: repo-sync/pull-request@v2 - with: - source_branch: "" # should be "nightly" as it's the triggering branch - destination_branch: "master" - pr_title: "Pulling ${{ github.ref_name }} into master" - pr_template: ".github/pr_release_template.md" - pr_assignee: "${{ secrets.GH_BOT_NAME }}" - pr_draft: true - pr_allow_empty: false - github_token: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml deleted file mode 100644 index 733b4de..0000000 --- a/.github/workflows/automerge.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -# This action is centrally managed in https://github.com//.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in -# the above-mentioned repo. - -# This workflow will, first, automatically approve PRs created by @LizardByte-bot. Then it will automerge relevant PRs. - -name: Automerge PR - -on: - pull_request: - types: - - opened - - synchronize - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - autoapprove: - if: >- - contains(fromJson('["LizardByte-bot"]'), github.event.pull_request.user.login) && - contains(fromJson('["LizardByte-bot"]'), github.actor) && - startsWith(github.repository, 'LizardByte/') - runs-on: ubuntu-latest - steps: - - name: Autoapproving - uses: hmarr/auto-approve-action@v3 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - name: Label autoapproved - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GH_BOT_TOKEN }} - script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ['autoapproved', 'autoupdate'] - }) - - automerge: - if: startsWith(github.repository, 'LizardByte/') - needs: [autoapprove] - runs-on: ubuntu-latest - - steps: - - name: Automerging - uses: pascalgn/automerge-action@v0.15.6 - env: - BASE_BRANCHES: nightly - GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} - GITHUB_LOGIN: ${{ secrets.GH_BOT_NAME }} - MERGE_LABELS: "!dependencies" - MERGE_METHOD: "squash" - MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" - MERGE_DELETE_BRANCH: true - MERGE_ERROR_FAIL: true - MERGE_FILTER_AUTHOR: ${{ secrets.GH_BOT_NAME }} - MERGE_RETRIES: "240" # 1 hour - MERGE_RETRY_SLEEP: "15000" # 15 seconds diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfed178..38e4f8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,22 +24,14 @@ jobs: matrix: include: - os: macos-latest - cmake_generator: "Unix Makefiles" - make_command: "make" shell: "bash" - os: ubuntu-latest appindicator: "libayatana-appindicator3-dev" - cmake_generator: "Unix Makefiles" - make_command: "make" shell: "bash" - os: ubuntu-latest appindicator: "libappindicator3-dev" - cmake_generator: "Unix Makefiles" - make_command: "make" shell: "bash" - os: windows-latest - cmake_generator: "MinGW Makefiles" - make_command: "mingw32-make" shell: "msys2 {0}" name: Build (${{ matrix.os }} - ${{ matrix.appindicator || 'default' }}) @@ -59,22 +51,32 @@ jobs: run: | sudo apt-get update sudo apt-get install -y \ + build-essential \ + cmake \ ${{ matrix.appindicator }} \ libglib2.0-dev \ libnotify-dev \ + ninja-build \ xvfb + - name: Setup Dependencies macOS + if: runner.os == 'macOS' + run: | + brew install \ + cmake \ + ninja + - name: Setup Dependencies Windows if: runner.os == 'Windows' uses: msys2/setup-msys2@v2 with: + msystem: ucrt64 update: true install: >- - base-devel - make - mingw-w64-x86_64-binutils - mingw-w64-x86_64-cmake - mingw-w64-x86_64-toolchain + mingw-w64-ucrt-x86_64-binutils + mingw-w64-ucrt-x86_64-cmake + mingw-w64-ucrt-x86_64-ninja + mingw-w64-ucrt-x86_64-toolchain - name: Setup python id: setup-python @@ -98,23 +100,21 @@ jobs: - name: Build run: | - mkdir build + mkdir -p build cd build - cmake \ - -G "${{ matrix.cmake_generator }}" \ - .. - ${{ matrix.make_command }} -j + cmake -DCMAKE_BUILD_TYPE:STRING=Debug -G Ninja .. + ninja - name: Run tests id: test - working-directory: build/tests + working-directory: build run: | if [ "${{ runner.os }}" = "Linux" ]; then export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & fi - ./test_tray --gtest_color=yes + ./tests/test_tray --gtest_color=yes - name: Generate gcov report # any except canceled or skipped @@ -123,12 +123,10 @@ jobs: working-directory: build run: | ${{ steps.python-path.outputs.python-path }} -m pip install gcovr - ${{ steps.python-path.outputs.python-path }} -m gcovr -r .. \ + ${{ steps.python-path.outputs.python-path }} -m gcovr . -r ../src \ --exclude-noncode-lines \ --exclude-throw-branches \ --exclude-unreachable-branches \ - --exclude '.*tests/.*' \ - --exclude '.*third-party/.*' \ --xml-pretty \ -o coverage.xml @@ -141,10 +139,12 @@ jobs: fi echo "flags=${flags}" >> $GITHUB_OUTPUT + # todo: upload coverage in separate job similar to LizardByte/libdisplaydevice - name: Upload coverage # any except canceled or skipped if: >- - always() && (steps.test_report.outcome == 'success') && + always() && + steps.test_report.outcome == 'success' && startsWith(github.repository, 'LizardByte/') uses: codecov/codecov-action@v4 with: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ae52487..934852d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,14 +9,14 @@ name: "CodeQL" on: push: - branches: ["master", "nightly"] + branches: ["master"] pull_request: - branches: ["master", "nightly"] + branches: ["master"] schedule: - cron: '00 12 * * 0' # every Sunday at 12:00 UTC concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: @@ -57,10 +57,27 @@ jobs: console.log(`Remapping language: ${key} to ${remap_languages[key.toLowerCase()]}`) key = remap_languages[key.toLowerCase()] } - if (supported_languages.includes(key.toLowerCase()) && - !matrix['include'].includes({"language": key.toLowerCase()})) { + if (supported_languages.includes(key.toLowerCase())) { console.log(`Found supported language: ${key}`) - matrix['include'].push({"language": key.toLowerCase()}) + let osList = ['ubuntu-latest']; + if (key.toLowerCase() === 'swift') { + osList = ['macos-latest']; + } else if (key.toLowerCase() === 'cpp') { + // TODO: update macos to latest after the below issue is resolved + // https://github.com/github/codeql-action/issues/2266 + osList = ['macos-13', 'ubuntu-latest', 'windows-latest']; + } + for (let os of osList) { + // set name for matrix + if (osList.length == 1) { + name = key.toLowerCase() + } else { + name = `${key.toLowerCase()}, ${os}` + } + + // add to matrix + matrix['include'].push({"language": key.toLowerCase(), "os": os, "name": name}) + } } } @@ -84,10 +101,15 @@ jobs: } analyze: - name: Analyze + name: Analyze (${{ matrix.name }}) if: ${{ needs.languages.outputs.continue == 'true' }} + defaults: + run: + shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }} + env: + GITHUB_CODEQL_BUILD: true needs: [languages] - runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + runs-on: ${{ matrix.os || 'ubuntu-latest' }} timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} permissions: actions: read @@ -100,9 +122,12 @@ jobs: steps: - name: Maximize build space - uses: easimon/maximize-build-space@v8 + if: >- + runner.os == 'Linux' && + matrix.language == 'cpp' + uses: easimon/maximize-build-space@v10 with: - root-reserve-mb: 20480 + root-reserve-mb: 30720 remove-dotnet: ${{ (matrix.language == 'csharp' && 'false') || 'true' }} remove-android: 'true' remove-haskell: 'true' @@ -114,6 +139,15 @@ jobs: with: submodules: recursive + - name: Setup msys2 + if: >- + runner.os == 'Windows' && + matrix.language == 'cpp' + uses: msys2/setup-msys2@v2 + with: + msystem: ucrt64 + update: true + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 @@ -129,16 +163,20 @@ jobs: # Pre autobuild # create a file named .codeql-prebuild-${{ matrix.language }}.sh in the root of your repository + # create a file named .codeql-build-${{ matrix.language }}.sh in the root of your repository - name: Prebuild + id: prebuild run: | - # check if .qodeql-prebuild-${{ matrix.language }}.sh exists - if [ -f "./.codeql-prebuild-${{ matrix.language }}.sh" ]; then - echo "Running .codeql-prebuild-${{ matrix.language }}.sh" - ./.codeql-prebuild-${{ matrix.language }}.sh + # check if prebuild script exists + filename=".codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh" + if [ -f "./${filename}" ]; then + echo "Running prebuild script: ${filename}" + ./${filename} fi # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - name: Autobuild + if: steps.prebuild.outputs.skip_autobuild != 'true' uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis diff --git a/.github/workflows/cpp-lint.yml b/.github/workflows/cpp-lint.yml index 921641c..5d0df5a 100644 --- a/.github/workflows/cpp-lint.yml +++ b/.github/workflows/cpp-lint.yml @@ -9,11 +9,11 @@ name: C++ Lint on: pull_request: - branches: [master, nightly] + branches: [master] types: [opened, synchronize, reopened] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: @@ -55,7 +55,7 @@ jobs: - name: Clang format lint if: ${{ steps.find_files.outputs.found_files }} - uses: DoozyX/clang-format-lint-action@v0.16.2 + uses: DoozyX/clang-format-lint-action@v0.17 with: source: ${{ steps.find_files.outputs.found_files }} extensions: 'cpp,h,m,mm' diff --git a/.github/workflows/python-flake8.yml b/.github/workflows/python-flake8.yml index e08ab10..61e23f7 100644 --- a/.github/workflows/python-flake8.yml +++ b/.github/workflows/python-flake8.yml @@ -9,11 +9,11 @@ name: flake8 on: pull_request: - branches: [master, nightly] + branches: [master] types: [opened, synchronize, reopened] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml index 7e1fd46..023b836 100644 --- a/.github/workflows/yaml-lint.yml +++ b/.github/workflows/yaml-lint.yml @@ -9,11 +9,11 @@ name: yaml lint on: pull_request: - branches: [master, nightly] + branches: [master] types: [opened, synchronize, reopened] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true jobs: