Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow CodeQL 运行失败 #307

Closed
tisfeng opened this issue Jan 5, 2024 · 8 comments
Closed

workflow CodeQL 运行失败 #307

tisfeng opened this issue Jan 5, 2024 · 8 comments
Labels

Comments

@tisfeng
Copy link
Owner

tisfeng commented Jan 5, 2024

这个 workflow 之前运行很好,我一直没动它,最近突然运行失败了 https://github.com/tisfeng/Easydict/actions/workflows/github-code-scanning/codeql

我看了一下,是从这个提交开始失败 https://github.com/tisfeng/Easydict/actions/runs/7367547129

中间间隔两个提交,是我将 AppCenter 和 firebase 从 Cocoapod 改成了 SPM,本地编译是没问题的,不知道为什么 CI 报错,我对 Swift 不太了解,不知道哪里出了问题。

@tisfeng tisfeng added the dev label Jan 5, 2024
@tisfeng
Copy link
Owner Author

tisfeng commented Jan 5, 2024

@Kyle-Ye 有空可以帮忙看看这个问题吗

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Jan 5, 2024

  1. The log has showed the error reason
image image
2023-12-31T02:28:35.9085640Z /Users/runner/work/Easydict/Easydict/Easydict/NewApp/View/MenuItemView.swift:92:1: error: expected expression
2023-12-31T02:28:35.9087060Z @available(macOS 13, *)
2023-12-31T02:28:35.9087490Z ^
2023-12-31T02:28:35.9088790Z /Users/runner/work/Easydict/Easydict/Easydict/NewApp/View/SettingView/Tabs/GeneralTab.swift:53:1: error: expected expression
2023-12-31T02:28:35.9090350Z @available(macOS 13, *)
2023-12-31T02:28:35.9090770Z ^
2023-12-31T02:28:35.9092030Z /Users/runner/work/Easydict/Easydict/Easydict/NewApp/View/SettingView/Tabs/AboutTab.swift:59:1: error: expected expression
2023-12-31T02:28:35.9093540Z @available(macOS 13, *)
2023-12-31T02:28:35.9093960Z ^
2023-12-31T02:28:35.9095680Z /Users/runner/work/Easydict/Easydict/Easydict/NewApp/View/MenuItemView.swift:66:13: error: cannot find 'SettingsLink' in scope
2023-12-31T02:28:35.9097250Z             SettingsLink()
2023-12-31T02:28:35.9097690Z             ^~~~~~~~~~~~
2023-12-31T02:28:35.9097980Z 

I believe this is because the CI is using Xcode_14.2.

And after #212, the minimal supported version to build the project is Xcode 15.0.

We can probably solve the issue by upgrading the CI's Xcode version.

  1. Maybe we can learn this as a lesson. Even the owner should not push code to protected branch(eg. dev) and a merge request and CI check is needed.
image

@tisfeng
Copy link
Owner Author

tisfeng commented Jan 5, 2024

目前项目使用的是 GitHub 仓库设置中的 CodeQL,我从 action 市场这里的配置文件看到已经是 macos-latest,也就是说是 macOS 13,那这里还能改吗?

https://github.com/tisfeng/Easydict/new/main?filename=.github%2Fworkflows%2Fcodeql.yml&workflow_template=code-scanning%2Fcodeql

    runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Jan 5, 2024

You may try to specify Xcode version to 15.0 and give it a try.

Also I noticing you are adding swift.yml workflow for swift build.

This will not work since the EasyDict project is a xcodeproj not a swift package.

For a Swift package, both swift build and xcodebuild is supported.
For a xcodeproje/xcodeworkspace, you still need to use xcodebuild manully.

  1. The easiest way to add such CI is by Xcode Cloud and Apple's Xcode Cloud team will take care of it. All you need to do is give Xcode Cloud the repo's read permission.
image

https://github.com/Kyle-Ye/MenuHelper

  1. Otherwise you need to explore the xcodebuild command, and run it in a GitHub workflow file

eg.

xcodebuild build \
            -scheme OpenSwiftUI \
            -configuration Debug \
            -skipMacroValidation -skipPackagePluginValidation \
            -destination "platform=iOS-Simulator" \

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Jan 5, 2024

目前项目使用的是 GitHub 仓库设置中的 CodeQL,我从 action 市场这里的配置文件看到已经是 macos-latest,也就是说是 macOS 13,那这里还能改吗?

tisfeng/Easydict/new/main?filename=.github%2Fworkflows%2Fcodeql.yml&workflow_template=code-scanning%2Fcodeql

    runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}

Every macOS runner image have a default Xcode version. And it will bundle a lot of different Xcode version.

See more info here https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md

In our case, we need to manually update the default Xcode version. You can do it by hand or using a Xcode action.(eg. https://github.com/maxim-lobanov/setup-xcode)

@tisfeng
Copy link
Owner Author

tisfeng commented Jan 5, 2024

ok,我先来试一下。

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Jan 5, 2024

ok,我先来试一下。

Most of my macOS project's CI is using Xcode Cloud. See I can't find a reference workflow file for you.

Here is a iOS one in case you need something for reference.

https://github.com/OpenSwiftUIProject/OpenSwiftUI/blob/9783793fc16cabb1b810a09f94f4faad2e00d7d7/.github/workflows/ios.yml#L10-L33

@tisfeng
Copy link
Owner Author

tisfeng commented Jan 6, 2024

CodeQL 已经修复了,通过指定 Runner Image 为 macos-13 和设置 xcode-version: '15.1' https://github.com/tisfeng/Easydict/blob/main/.github/workflows/codeql.yml

之前没注意 macos-latest 居然是 macos-12,这太坑了 🥲

Runner Image
  Image: macos-12
  Version: 20231216.1
  Included Software: https://github.com/actions/runner-images/blob/macOS-12/20231216.1/images/macos/macos-12-Readme.md
  Image Release: https://github.com/actions/runner-images/releases/tag/macOS-12%2F20231216.1

@tisfeng tisfeng closed this as completed Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants