This repository has been archived by the owner on Mar 31, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Add cargo actions #102
Merged
Merged
Add cargo actions #102
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
415dfca
data/macros/actions: Add support for cargo
livingsilver94 ccc32c5
drafter: Add support for Cargo projects
livingsilver94 b8f8673
Add cargo actions
tarkah 5ce8389
Implement Build interface for CargoBuild
tarkah 8bcecd2
Rename module to cargo
tarkah 0f6f67d
Fix header
tarkah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,38 @@ | ||
actions: | ||
# Fetch dependencies | ||
- cargo_fetch: | ||
command: | | ||
cargo fetch -v --locked | ||
dependencies: | ||
- rust | ||
|
||
# Build the rust project | ||
- cargo_build: | ||
command: | | ||
cargo build -v -j "%(jobs)" --frozen --release --target %(target_triple) \ | ||
--config profile.release.debug=\"full\" \ | ||
--config profile.release.split-debuginfo=\"off\" \ | ||
--config profile.release.strip=\"none\" | ||
dependencies: | ||
- rust | ||
|
||
# Install the built binary | ||
- cargo_install: | ||
command: | | ||
cargo_install(){ | ||
if [ $# -eq 1 ]; then | ||
%install_bin target/%(target_triple)/release/"$1" | ||
else | ||
%install_bin target/%(target_triple)/release/%(name) | ||
fi | ||
} | ||
cargo_install | ||
dependencies: | ||
- rust | ||
|
||
# Run tests | ||
- cargo_test: | ||
command: | | ||
cargo test -v -j "%(jobs)" --frozen --release --target %(target_triple) --workspace | ||
dependencies: | ||
- rust |
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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* SPDX-License-Identifier: Zlib */ | ||
|
||
/** | ||
* Drafter - Python integration | ||
* | ||
* Authors: © 2020-2022 Serpent OS Developers | ||
* License: Zlib | ||
*/ | ||
|
||
module drafter.build.cargo; | ||
|
||
import moss.deps.analysis; | ||
import drafter : Drafter; | ||
import drafter.build : BuildType, Build; | ||
import std.path : baseName; | ||
|
||
/** | ||
* Discover Cargo projects. | ||
*/ | ||
static private AnalysisReturn acceptCargo(scope Analyser an, ref FileInfo inpath) | ||
{ | ||
Drafter c = an.userdata!Drafter; | ||
|
||
switch (inpath.path.baseName) | ||
{ | ||
case "Cargo.toml": | ||
c.incrementBuildConfidence(BuildType.Cargo, 100); | ||
return AnalysisReturn.IncludeFile; | ||
default: | ||
return AnalysisReturn.NextHandler; | ||
} | ||
} | ||
|
||
/** | ||
* Handler for Cargo projects. | ||
*/ | ||
public static AnalysisChain cargoChain = AnalysisChain("cargo", [&acceptCargo], 20); | ||
|
||
public final class CargoBuild : Build | ||
{ | ||
override: | ||
|
||
string setup() | ||
{ | ||
return "%cargo_fetch"; | ||
} | ||
|
||
string build() | ||
{ | ||
return "%cargo_build"; | ||
} | ||
|
||
string install() | ||
{ | ||
return "%cargo_install"; | ||
} | ||
|
||
string check() | ||
{ | ||
return "%cargo_check"; | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird -- as if there's an encoding issue?
Feel free to update Copyright year range as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 👍