Skip to content

Commit

Permalink
ci: upload artifacts (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaoboy authored Sep 19, 2024
1 parent 62b60c9 commit 70c37b4
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 86 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: build artifacts
on: workflow_call

jobs:
build-artifacts:
strategy:
fail-fast: ${{ startsWith(github.ref, 'refs/tags/') }}
matrix:
include:
- os: windows-latest
platform: windows
arch: x86_64
release: x64
toolchain: nightly-x86_64-pc-windows-gnu
RUSTFLAGS: -C target-feature=+crt-static
- os: ubuntu-latest
platform: linux
arch: x86_64
release: x64
toolchain: nightly
- os: ubuntu-latest
platform: linux
arch: aarch64
release: arm64
toolchain: nightly
- os: macos-latest
platform: darwin
arch: x86_64
release: x64
toolchain: nightly
- os: macos-latest
platform: darwin
arch: aarch64
release: arm64
toolchain: nightly

uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
release: ${{ matrix.release }}
toolchain: ${{ matrix.toolchain }}
2 changes: 1 addition & 1 deletion .github/workflows/build-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
type: string

jobs:
build:
build-modules:
runs-on: ${{ inputs.os }}
steps:
- name: Checkout
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ on:
required: false
type: string
toolchain:
required: true
required: false
type: string
default: "nightly"

jobs:
build:
runs-on: ${{ inputs.os }}
Expand Down
33 changes: 2 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,10 @@ jobs:
echo "console.log(123);" > "bundle/js/test$i.js"
done
cargo clippy --all-targets --all-features -- -D warnings
build:
build-artifacts:
needs:
- check
strategy:
fail-fast: ${{ startsWith(github.ref, 'refs/tags/') }}
matrix:
include:
- os: windows-latest
platform: windows
arch: x86_64
toolchain: nightly-x86_64-pc-windows-gnu
- os: ubuntu-latest
platform: linux
arch: x86_64
toolchain: nightly
- os: ubuntu-latest
platform: linux
arch: aarch64
toolchain: nightly
- os: macos-latest
platform: darwin
arch: x86_64
toolchain: nightly
- os: macos-latest
platform: darwin
arch: aarch64
toolchain: nightly
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
toolchain: ${{ matrix.toolchain }}
uses: ./.github/workflows/build-artifacts.yml
modules:
needs:
- check
Expand Down
43 changes: 4 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,16 @@ on:
- "v*.*.*"

jobs:
build:
strategy:
fail-fast: ${{ startsWith(github.ref, 'refs/tags/') }}
matrix:
include:
- os: windows-latest
platform: windows
arch: x86_64
release: x64
toolchain: nightly-x86_64-pc-windows-gnu
- os: ubuntu-latest
platform: linux
arch: x86_64
release: x64
toolchain: nightly
- os: ubuntu-latest
platform: linux
arch: aarch64
release: arm64
toolchain: nightly
- os: macos-latest
platform: darwin
arch: x86_64
release: x64
toolchain: nightly
- os: macos-latest
platform: darwin
arch: aarch64
release: arm64
toolchain: nightly
build-artifacts:
uses: ./.github/workflows/build-artifacts.yml

uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
release: ${{ matrix.release }}
toolchain: ${{ matrix.toolchain }}
release:
permissions:
contents: write
discussions: write
runs-on: ubuntu-latest
needs:
- build
- build-artifacts
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -94,7 +59,7 @@ jobs:
./llrt-windows-x64-full-sdk.zip
publish:
needs:
- build
- build-artifacts
uses: ./.github/workflows/publish.yml
with:
ref: ${{ github.ref }}
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ llrt-lambda-${1}${2}.zip: export SDK_BUNDLE_MODE = ${3}
llrt-lambda-${1}${2}.zip: | clean-js js
cargo $$(BUILD_ARG) --target $$(TARGET_linux_$$(RELEASE_ARCH_NAME_${1})) --features lambda
./pack target/$$(TARGET_linux_$$(RELEASE_ARCH_NAME_${1}))/release/llrt target/$$(TARGET_linux_$$(RELEASE_ARCH_NAME_${1}))/release/bootstrap
@rm -rf $$@
@rm -rf $$@
zip -j $$@ target/$$(TARGET_linux_$$(RELEASE_ARCH_NAME_${1}))/release/bootstrap

llrt-container-${1}${2}: export SDK_BUNDLE_MODE = ${3}
Expand All @@ -80,20 +80,20 @@ llrt-container-${1}${2}: | clean-js js
llrt-linux-${1}${2}.zip: export SDK_BUNDLE_MODE = ${3}
llrt-linux-${1}${2}.zip: | clean-js js
cargo $$(BUILD_ARG) --target $$(TARGET_linux_$$(RELEASE_ARCH_NAME_${1}))
@rm -rf $$@
@rm -rf $$@
zip -j $$@ target/$$(TARGET_linux_$$(RELEASE_ARCH_NAME_${1}))/release/llrt

llrt-darwin-${1}${2}.zip: export SDK_BUNDLE_MODE = ${3}
llrt-darwin-${1}${2}.zip: | clean-js js
cargo $$(BUILD_ARG) --target $$(TARGET_darwin_$$(RELEASE_ARCH_NAME_${1}))
@rm -rf $$@
@rm -rf $$@
zip -j $$@ target/$$(TARGET_darwin_$$(RELEASE_ARCH_NAME_${1}))/release/llrt

# llrt-windows-arm64* is automatically generated, but not currently supported.
llrt-windows-${1}${2}.zip: export SDK_BUNDLE_MODE = ${3}
llrt-windows-${1}${2}.zip: | clean-js js
cargo $$(BUILD_ARG) --target $$(TARGET_windows_$$(RELEASE_ARCH_NAME_${1}))
zip -j $$@ target/$$(TARGET_windows_$$(RELEASE_ARCH_NAME_${1}))/release/llrt/release/llrt.exe
zip -j $$@ target/$$(TARGET_windows_$$(RELEASE_ARCH_NAME_${1}))/release/llrt.exe
endef

$(foreach target,$(RELEASE_TARGETS),$(eval $(call release_template,$(target),-full-sdk,FULL)))
Expand Down
19 changes: 16 additions & 3 deletions llrt_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ fn compress_bytecode(dictionary_path: String, source_files: Vec<String>) -> io::

fn generate_compression_dictionary(
dictionary_path: &str,
source_files: &Vec<String>,
source_files: &[String],
) -> Result<(), io::Error> {
info!("Generating compression dictionary...");
let file_count = source_files.len();
let mut dictionary_filenames = source_files.clone();
let mut dictionary_filenames = source_files.to_owned();
let mut dictionary_file_set: HashSet<String> = HashSet::from_iter(dictionary_filenames.clone());
let mut cmd = Command::new("zstd");
cmd.args([
Expand All @@ -265,7 +265,20 @@ fn generate_compression_dictionary(
dictionary_filenames = dictionary_file_set.into_iter().collect();
}
cmd.args(&dictionary_filenames);
let mut cmd = cmd.args(source_files).spawn()?;

// To avoid cmd being too long to execute
let out_dir = env::var("OUT_DIR").unwrap();
let short_source_files: Vec<_> = source_files
.iter()
.map(|i| {
Path::new(i)
.strip_prefix(out_dir.clone())
.unwrap()
.to_string_lossy()
.to_string()
})
.collect();
let mut cmd = cmd.current_dir(out_dir).args(short_source_files).spawn()?;
let exit_status = cmd.wait()?;
if !exit_status.success() {
return Err(io::Error::new(
Expand Down
4 changes: 2 additions & 2 deletions llrt_modules/src/modules/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn prepare_shell_args(
{
if shell_is_cmd {
*windows_verbatim_arguments = true;
string_args.insert_str(0, "\"");
string_args.insert(0, '"');
}
}

Expand All @@ -116,7 +116,7 @@ fn prepare_shell_args(
#[cfg(windows)]
{
if shell_is_cmd {
string_args.push_str("\"");
string_args.push('"');
return vec![
String::from("/d"),
String::from("/s"),
Expand Down
4 changes: 1 addition & 3 deletions llrt_modules/src/modules/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ fn find_next_separator(s: &str) -> Option<usize> {

#[cfg(windows)]
fn find_last_sep(path: &str) -> Option<usize> {
memchr::memchr2_iter(b'\\', b'/', path.as_bytes())
.rev()
.next()
memchr::memchr2_iter(b'\\', b'/', path.as_bytes()).next_back()
}

#[cfg(not(windows))]
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,16 @@ describe("JSON Stringified", () => {
});

it("should stringify and remove objects that are not valid json", () => {
const dateString = new Date().toJSON();
const now = new Date()
const dateString = now.toJSON();
const data = {
a: "123",
b: undefined,
c: () => {
return "123";
},
d: RegExp("apa"),
e: new Date(),
e: now,
};
expect(JSON.stringify(data)).toEqual(
`{"a":"123","d":{},"e":"${dateString}"}`
Expand Down

0 comments on commit 70c37b4

Please sign in to comment.