我在 GitHub Actions 中遇到了最奇怪的错误,我已经尝试解决这个错误好几个小时了,但我完全没有想法。
我目前使用一个非常简单的 GitHub Action。最终目标是在其他工作流程中通过 ssh 运行特定的 bash 命令。
Dockerfile:
FROM ubuntu:latest
COPY entrypoint.sh /entrypoint.sh
RUN apt update && apt install openssh-client -y
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Run Code Online (Sandbox Code Playgroud)
入口点.sh:
FROM ubuntu:latest
COPY entrypoint.sh /entrypoint.sh
RUN apt update && apt install openssh-client -y
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Run Code Online (Sandbox Code Playgroud)
动作.yml
name: "SSH Runner"
description: "Runs bash commands in remote server via SSH"
inputs:
ssh_key:
description: 'SSH Key'
known_hosts:
description: 'Known Hosts'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- …Run Code Online (Sandbox Code Playgroud) ssh continuous-integration continuous-deployment docker github-actions
我目前正在尝试使用 Flutter 和 Dart 进行测试驱动开发。我有一个对象,它有两个方法,第一个方法执行 http 调用,第二个方法调用第一个方法。为了测试第一个函数,我模拟了该函数的依赖关系(即 http 调用)。
现在我想测试第二种方法,但我无法找到一种方法来仅模拟第一个函数,同时保持对象的其余部分完好无损。因此,我只能再次模拟第一个方法的依赖关系,这会导致整个函数被重新执行。这违背了单元测试的整个目的。
在模拟对象方面,似乎只有全有或全无的方法。我想知道如何处理某些对象依赖于同一对象上的方法的情况。使用FakeandMock不允许我调用原始方法。spy已弃用,并且将模拟函数分配给其中一个函数不起作用,因为 Dart 不允许我重新分配方法。
我正在尝试从屏幕上获取显示器指定部分的像素颜色。我曾经CGDIsplayCreateImage(_:)这样做过,但由于某种原因,它没有创建当前打开的窗口的屏幕截图,而是只提供了壁纸和任务栏的图像。
为了可视化屏幕截图,我使用了 SwiftUI 视图。在我的应用程序中,我实际上不需要显示屏幕截图。
struct ScreenshotView: View {
let cgImage: CGImage
var body: some View {
Image(decorative: cgImage, scale: 3)
}
}
Run Code Online (Sandbox Code Playgroud)
这些applicationDidFinishLaunching(_:)方法看起来像这样。
func applicationDidFinishLaunching(_ aNotification: Notification) {
let contentRect = NSRect(x: 0, y: 0, width: 240, height: 240)
// Create the window and set the content view.
window = NSWindow(
contentRect: contentRect,
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
backing: .buffered, defer: false)
window.center()
window.setFrameAutosaveName("Main Window")
window.contentView = NSHostingView(rootView: ScreenshotView(cgImage: CGDisplayCreateImage(CGMainDisplayID())!))
window.makeKeyAndOrderFront(nil)
}
Run Code Online (Sandbox Code Playgroud)
由于 XCode 和其他一些应用程序已打开,因此它应该为我提供所有打开的 …