-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: cargo near new integration test + gh workflow to autorenew image …
…tag/digest (#235)
- Loading branch information
Showing
21 changed files
with
463 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: renew docker image tag and digest periodically and on-demand | ||
|
||
on: | ||
schedule: | ||
- cron: '0 1 * * *' # Runs daily at 1 hour after midnight | ||
workflow_dispatch: | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
jobs: | ||
check_latest_docker_image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
|
||
- uses: hustcer/setup-nu@v3 | ||
with: | ||
version: "*" | ||
|
||
- name: Run update script | ||
shell: nu {0} | ||
run: | | ||
let record = http get "https://hub.docker.com/v2/namespaces/sourcescan/repositories/cargo-near/tags" | get results | first; | ||
let mod_content = ( | ||
open cargo-near/src/commands/new/new-project-template/Cargo.toml.template --raw | lines | ||
| each { | ||
|line| if ($line | str starts-with "image = ") { | ||
$'image = "sourcescan/cargo-near:($record.name)"' | ||
} else { $line } | ||
} | ||
| each { | ||
|line| if ($line | str starts-with "image_digest = ") { | ||
$'image_digest = "($record.digest)"' | ||
} else { $line } | ||
} | ||
| to text | ||
); | ||
$mod_content | save -f cargo-near/src/commands/new/new-project-template/Cargo.toml.template | ||
git diff | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
title: update `cargo near new` template `image` and `image_digest` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,11 @@ jobs: | |
run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev | ||
|
||
- name: Cargo check | ||
env: | ||
# info: (overridden by '/home/runner/work/cargo-near/cargo-near/rust-toolchain.toml') | ||
RUSTUP_TOOLCHAIN: ${{ env.RUST_MSRV }} | ||
run: | | ||
rustc -vV | ||
cargo check -p cargo-near | ||
cargo check -p cargo-near-build --all-features | ||
|
@@ -56,9 +60,9 @@ jobs: | |
- name: "Install stable Rust toolchain" | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
# channel is really controlled by ./rust-toolchain.toml | ||
toolchain: stable | ||
default: true | ||
profile: minimal | ||
|
||
- name: Install `wasm32-unknown-unknown` | ||
run: rustup target add wasm32-unknown-unknown | ||
|
@@ -68,7 +72,10 @@ jobs: | |
run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev | ||
|
||
- name: Run tests | ||
run: cargo test --workspace | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "nearprotocol-ci" | ||
cargo test --workspace | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,4 @@ docker = [ | |
"dep:nix", | ||
"dep:shell-words", | ||
] | ||
test_code = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name = "cargo-near" | |
version = "0.10.1" | ||
authors = ["Near Inc <[email protected]>"] | ||
edition = "2021" | ||
rust-version = "1.78.0" | ||
rust-version = "1.79.0" | ||
description = "Cargo extension for building Rust smart contracts on NEAR" | ||
readme = "README.md" | ||
repository = "https://github.com/near/cargo-near" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,10 @@ impl NewContext { | |
.replace( | ||
"cargo-near-new-ci-tool-version-self", | ||
env!("CARGO_PKG_VERSION"), | ||
) | ||
.replace( | ||
"TEST_BASICS_ON_INCLUDE", | ||
include_str!("./test_basics_on.rs.in"), | ||
), | ||
) | ||
.wrap_err_with(|| format!("Failed to write to file: {}", new_file_path.display()))?; | ||
|
@@ -96,17 +100,20 @@ impl NewContext { | |
)); | ||
} | ||
|
||
let status = std::process::Command::new("git") | ||
let child = std::process::Command::new("git") | ||
.arg("commit") | ||
.arg("-m") | ||
.arg("init") | ||
.arg("--author=nearprotocol-ci <[email protected]>") | ||
.current_dir(project_dir) | ||
.stdout(Stdio::null()) | ||
.stderr(Stdio::null()) | ||
.status()?; | ||
if !status.success() { | ||
.stdout(Stdio::piped()) | ||
.stderr(Stdio::piped()) | ||
.spawn()?; | ||
let output = child.wait_with_output()?; | ||
if !output.status.success() { | ||
println!("{}", String::from_utf8_lossy(&output.stderr)); | ||
return Err(color_eyre::eyre::eyre!( | ||
"Failed to execute process: `git commit -m init`" | ||
"Failed to execute process: `git commit -m init --author='nearprotocol-ci <[email protected]>'`" | ||
)); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.