From 137186750e3d6d76051f4152cb02099fcdcfd2bb Mon Sep 17 00:00:00 2001 From: Konrad `ktoso` Malawski Date: Sat, 20 Jan 2024 01:23:57 +0900 Subject: [PATCH 1/5] Workaround for process terminate() not working reliably on linux Process.terminate() has a known issue on corelibs foundation (on linux): https://github.com/apple/swift-corelibs-foundation/issues/4772 Instead, we should SIGKILL the process on Linux as a workaround. This will lead to reliably cleaning up pkl/jpkl processes. --- Sources/PklSwift/MessageTransport.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/PklSwift/MessageTransport.swift b/Sources/PklSwift/MessageTransport.swift index baabdaa..29e1db6 100644 --- a/Sources/PklSwift/MessageTransport.swift +++ b/Sources/PklSwift/MessageTransport.swift @@ -124,7 +124,14 @@ public class ChildProcessMessageTransport: MessageTransport { if self.process == nil { return } - self.process!.terminate() + #if os(Linux) + // workaround: https://github.com/apple/swift-corelibs-foundation/issues/4772 + if let process = self.process, process.isRunning { + kill(process.processIdentifier, SIGKILL) + } + #else + self.process?.terminate() + #endif self.process!.waitUntilExit() self.process = nil } From ed5edcdcd46deb66465925dad566e090253a0e7f Mon Sep 17 00:00:00 2001 From: Dan Chao Date: Mon, 22 Jan 2024 14:38:42 -0800 Subject: [PATCH 2/5] Re-generate config.yml --- .circleci/config.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7d653b1..a79210b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ # Generated from CircleCI.pkl. DO NOT EDIT. version: 2.1 orbs: - pr-approval: pkl-lang/pr-approval@dev:4 + pr-approval: apple/pr-approval@0.1.0 jobs: test: steps: @@ -127,7 +127,14 @@ jobs: workflows: prb: jobs: - - test + - hold: + type: approval + - pr-approval/authenticate: + context: pkl-pr-approval + - test: + requires: + - hold + - pr-approval/authenticate when: matches: value: << pipeline.git.branch >> @@ -141,7 +148,11 @@ workflows: - << pipeline.git.branch >> release: jobs: + - hold: + type: approval - test: + requires: + - hold filters: branches: ignore: /.*/ @@ -150,6 +161,7 @@ workflows: - pkl-package: requires: - test + - hold filters: branches: ignore: /.*/ @@ -158,6 +170,7 @@ workflows: - pkl-gen-swift-macos: requires: - test + - hold filters: branches: ignore: /.*/ @@ -166,6 +179,7 @@ workflows: - pkl-gen-swift-linux-amd64: requires: - test + - hold filters: branches: ignore: /.*/ @@ -174,6 +188,7 @@ workflows: - pkl-gen-swift-linux-aarch64: requires: - test + - hold filters: branches: ignore: /.*/ @@ -185,6 +200,7 @@ workflows: - pkl-gen-swift-macos - pkl-gen-swift-linux-amd64 - pkl-gen-swift-linux-aarch64 + - hold context: - Pkl release filters: From 41d4d4f67fd1e6d04d7791f91f26c57fa6d861ec Mon Sep 17 00:00:00 2001 From: Dan Chao Date: Mon, 22 Jan 2024 16:55:13 -0800 Subject: [PATCH 3/5] Disable approval job --- .circleci/config.pkl | 6 ++---- .circleci/config.yml | 24 +++--------------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/.circleci/config.pkl b/.circleci/config.pkl index 4b66a86..996b774 100644 --- a/.circleci/config.pkl +++ b/.circleci/config.pkl @@ -77,12 +77,10 @@ jobs { resource_class = "xlarge" // TODO(oss) remove me, and download Pkl from CI environment { - ["PKL_EXEC"] = "bin/jpkl" + ["PKL_EXEC"] = "bin/pkl-cli-macos-amd64" } steps { "checkout" - // need to use jpkl because of an issue where pkl refuses to exit - new RunStep { command = "yum install -y java" } swiftTest new RunStep { command = "make test-snippets" } new RunStep { command = "make test-pkl" } @@ -97,6 +95,7 @@ jobs { macos { xcode = "15.2.0" } + resource_class = "macos.m1.large.gen1" steps { "checkout" new RunStep { @@ -189,7 +188,6 @@ jobs { out/pkl-package/* echo "Creating release for Swift library" - export GH_TOKEN="${GITHUB_TOKEN}" gh release create "${CIRCLE_TAG}" \ --title "${CIRCLE_TAG}" \ --target "${CIRCLE_SHA1}" \ diff --git a/.circleci/config.yml b/.circleci/config.yml index a79210b..a5a6766 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,8 +6,6 @@ jobs: test: steps: - checkout - - run: - command: yum install -y java - run: command: |- mkdir -p .out/test-results/ @@ -22,7 +20,7 @@ jobs: - store_test_results: path: .out/test-results/ environment: - PKL_EXEC: bin/jpkl + PKL_EXEC: bin/pkl-cli-macos-amd64 resource_class: xlarge docker: - image: swift:5.9-rhel-ubi9 @@ -40,6 +38,7 @@ jobs: root: '.' paths: - out/ + resource_class: macos.m1.large.gen1 macos: xcode: 15.2.0 pkl-gen-swift-linux-aarch64: @@ -111,7 +110,6 @@ jobs: out/pkl-package/* echo "Creating release for Swift library" - export GH_TOKEN="${GITHUB_TOKEN}" gh release create "${CIRCLE_TAG}" \ --title "${CIRCLE_TAG}" \ --target "${CIRCLE_SHA1}" \ @@ -127,14 +125,7 @@ jobs: workflows: prb: jobs: - - hold: - type: approval - - pr-approval/authenticate: - context: pkl-pr-approval - - test: - requires: - - hold - - pr-approval/authenticate + - test when: matches: value: << pipeline.git.branch >> @@ -148,11 +139,7 @@ workflows: - << pipeline.git.branch >> release: jobs: - - hold: - type: approval - test: - requires: - - hold filters: branches: ignore: /.*/ @@ -161,7 +148,6 @@ workflows: - pkl-package: requires: - test - - hold filters: branches: ignore: /.*/ @@ -170,7 +156,6 @@ workflows: - pkl-gen-swift-macos: requires: - test - - hold filters: branches: ignore: /.*/ @@ -179,7 +164,6 @@ workflows: - pkl-gen-swift-linux-amd64: requires: - test - - hold filters: branches: ignore: /.*/ @@ -188,7 +172,6 @@ workflows: - pkl-gen-swift-linux-aarch64: requires: - test - - hold filters: branches: ignore: /.*/ @@ -200,7 +183,6 @@ workflows: - pkl-gen-swift-macos - pkl-gen-swift-linux-amd64 - pkl-gen-swift-linux-aarch64 - - hold context: - Pkl release filters: From ebe558ccf455473bf8137cbd2c698544957b7e0b Mon Sep 17 00:00:00 2001 From: Dan Chao Date: Mon, 22 Jan 2024 16:56:31 -0800 Subject: [PATCH 4/5] Fix path to pkl --- .circleci/config.pkl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.pkl b/.circleci/config.pkl index 996b774..976af9c 100644 --- a/.circleci/config.pkl +++ b/.circleci/config.pkl @@ -77,7 +77,7 @@ jobs { resource_class = "xlarge" // TODO(oss) remove me, and download Pkl from CI environment { - ["PKL_EXEC"] = "bin/pkl-cli-macos-amd64" + ["PKL_EXEC"] = "bin/pkl-cli-amd64" } steps { "checkout" From 99bd7b99bc878e9838451cbb9b6819186d6da162 Mon Sep 17 00:00:00 2001 From: Dan Chao Date: Mon, 22 Jan 2024 17:12:39 -0800 Subject: [PATCH 5/5] Fix path to pkl --- .circleci/config.pkl | 2 +- .circleci/config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.pkl b/.circleci/config.pkl index 976af9c..d51bc02 100644 --- a/.circleci/config.pkl +++ b/.circleci/config.pkl @@ -77,7 +77,7 @@ jobs { resource_class = "xlarge" // TODO(oss) remove me, and download Pkl from CI environment { - ["PKL_EXEC"] = "bin/pkl-cli-amd64" + ["PKL_EXEC"] = "bin/pkl-cli-amd64.bin" } steps { "checkout" diff --git a/.circleci/config.yml b/.circleci/config.yml index a5a6766..564caae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ jobs: - store_test_results: path: .out/test-results/ environment: - PKL_EXEC: bin/pkl-cli-macos-amd64 + PKL_EXEC: bin/pkl-cli-amd64.bin resource_class: xlarge docker: - image: swift:5.9-rhel-ubi9