Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d16a6da
Add `console.log`
franciszekjob Jun 23, 2025
93c7f66
Fix resolving scarb version
franciszekjob Jun 23, 2025
405d7e0
Change version in `Test local action`
franciszekjob Jun 23, 2025
861d4dd
Remove windows from os matrix
franciszekjob Jun 23, 2025
5dc5516
Remove running tests on windows
franciszekjob Jun 23, 2025
a62bfba
Run `npm run build`
franciszekjob Jun 23, 2025
61851e0
Simplify `determineVersion`
franciszekjob Jun 23, 2025
c4b042d
Remove running tests on Windows
franciszekjob Jun 23, 2025
c68e4cc
Merge branch 'remove-windows-support' of https://github.com/foundry-r…
franciszekjob Jun 23, 2025
0bf54e7
Fix variable name
franciszekjob Jun 23, 2025
34439c6
Fix resolving scarb version
franciszekjob Jun 23, 2025
84d0154
Merge branch 'remove-windows-support' of https://github.com/foundry-r…
franciszekjob Jun 23, 2025
ef39d4d
Another console.log
franciszekjob Jun 23, 2025
9c90e4b
Update console.log
franciszekjob Jun 23, 2025
2a508b3
Update console.log
franciszekjob Jun 23, 2025
e578c43
Add console.log
franciszekjob Jun 23, 2025
d383ccf
More logs
franciszekjob Jun 23, 2025
d6e4028
More logs
franciszekjob Jun 23, 2025
f386c58
Logs
franciszekjob Jun 23, 2025
a79c96e
Refactor `action.yml`
franciszekjob Jun 23, 2025
bef02b5
Little changes
franciszekjob Jun 23, 2025
d1523f8
Fix `determineVersion`
franciszekjob Jun 23, 2025
888756c
Include USC setup
franciszekjob Jun 23, 2025
d2cfeeb
Add envs in `action.yml`
franciszekjob Jun 23, 2025
2eb202b
Code cleanup
franciszekjob Jun 23, 2025
7887a96
Run `npm run build`
franciszekjob Jun 23, 2025
7e8373d
Remove console logs
franciszekjob Jun 23, 2025
04612c0
Add console.log
franciszekjob Jun 23, 2025
c20bc33
Add test for fixed version
franciszekjob Jun 23, 2025
a28ce41
Little refactor for fixed version validation
franciszekjob Jun 23, 2025
091271f
Formatting
franciszekjob Jun 23, 2025
249adeb
Temporarily change fixed version to make workflow fail
franciszekjob Jun 23, 2025
fd8d220
Refactor `Verify snforge version`
franciszekjob Jun 23, 2025
454f5cb
Restore correct version
franciszekjob Jun 23, 2025
099203e
Run `npm run build`
franciszekjob Jun 23, 2025
2029567
Refactor
franciszekjob Jun 23, 2025
86f87a6
Use `actions/checkout@v4` instead of v3
franciszekjob Jun 23, 2025
43e881b
Trigger CI
franciszekjob Jun 23, 2025
4307c6a
Temporarily change way, how `StarknetFoundryVersionInput` is determined
franciszekjob Jun 23, 2025
d687d35
Formatting
franciszekjob Jun 23, 2025
43da8b8
Formatting
franciszekjob Jun 23, 2025
0584815
Revert "Formatting"
franciszekjob Jun 23, 2025
e41727e
Add `workflow_dispatch`
franciszekjob Jun 23, 2025
527d558
Trigger CI
franciszekjob Jun 23, 2025
e97bad4
Fix `checks.yml`
franciszekjob Jun 23, 2025
adb34ba
Fix `checks.yml`
franciszekjob Jun 23, 2025
fc10d70
Code cleanup
franciszekjob Jun 23, 2025
a7d2f97
Restore previous logic in `determineVersion`
franciszekjob Jun 24, 2025
c296f21
Merge branch 'main' into 31-fix-determining-version
franciszekjob Jun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set Node.js 20.x
uses: actions/setup-node@v3
Expand Down
46 changes: 34 additions & 12 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20.x
Expand All @@ -26,19 +26,16 @@ jobs:
run: npm run fmt:check

test-action:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get scarb version
id: extractScarbVersion
shell: bash
run: |
snfoundry_version=$(curl -s https://api.github.com/repos/foundry-rs/starknet-foundry/releases/latest | grep tarball_url | awk -F '/' '{print $8}' | tr -d '",')
version=$(curl -s https://raw.githubusercontent.com/foundry-rs/starknet-foundry/$snfoundry_version/.tool-versions | awk '{print $2}')
version=$(curl -s https://raw.githubusercontent.com/foundry-rs/starknet-foundry/$snfoundry_version/.tool-versions | grep '^scarb' | awk '{print $2}')

echo "scarbVersion=$version" >> "$GITHUB_OUTPUT"
- name: Setup Scarb
Expand All @@ -62,12 +59,9 @@ jobs:
working-directory: myproject

test-action-with-tools-file:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: "Create .tool-versions file"
shell: bash
Expand All @@ -81,3 +75,31 @@ jobs:

- run: snforge --version | grep "snforge 0.16.0"
shell: bash

test-action-with-fixed-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: "Setup Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: 2.9.4

- name: "Setup foundry using fixed version"
uses: ./
with:
starknet-foundry-version: 0.44.0

- name: Verify snforge version
run: |
EXPECTED="snforge 0.44.0"
VERSION=$(snforge --version)

echo "Expected version: $EXPECTED"
echo "Actual version: $VERSION"

if [[ "$VERSION" != "$EXPECTED" ]]; then
echo "Version mismatch"
exit 1
fi
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ runs:
- name: Set up Starknet Foundry
shell: bash
run: node $GITHUB_ACTION_PATH/dist/index.js
env:
INPUT_STARKNET-FOUNDRY-VERSION: ${{ inputs.starknet-foundry-version }}
INPUT_TOOL-VERSIONS: ${{ inputs.tool-versions }}
36 changes: 12 additions & 24 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29819,40 +29819,28 @@ async function getFullVersionFromStarknetFoundry() {
return match[1];
}

async function determineVersion(version, toolVersionsPath, repo) {
version = version?.trim();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async function determineVersion(
versionFromInput,
toolVersionsPath,
repo,
) {
const versionFromFile = toolVersionsPath
? await getVersionFromToolVersionsFile(toolVersionsPath)
: await getVersionFromToolVersionsFile();

if (version && toolVersionsPath) {
if (versionFromInput && toolVersionsPath) {
throw new Error(
"the `starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
"`starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
);
}

if (toolVersionsPath) {
let toolVersion = await getVersionFromToolVersionsFile(toolVersionsPath);

if (!toolVersion) {
throw new Error(
`failed to read Starknet Foundry version from: ${toolVersionsPath}`,
);
}
version = toolVersion;
}

if (!version) {
let toolVersion = await getVersionFromToolVersionsFile();
version = toolVersion ?? "latest";
}
let version = versionFromInput || versionFromFile || "latest";

if (version === "latest") {
version = await fetchLatestTag(repo);
}

if (version.startsWith("v")) {
version = version.substring(1);
}

return version;
return version.startsWith("v") ? version.slice(1) : version;
}

function fetchLatestTag(repo) {
Expand Down
38 changes: 13 additions & 25 deletions lib/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,28 @@ export async function getFullVersionFromStarknetFoundry() {
return match[1];
}

export async function determineVersion(version, toolVersionsPath, repo) {
version = version?.trim();

if (version && toolVersionsPath) {
export async function determineVersion(
versionFromInput,
toolVersionsPath,
repo,
) {
const versionFromFile = toolVersionsPath
? await getVersionFromToolVersionsFile(toolVersionsPath)
: await getVersionFromToolVersionsFile();

if (versionFromInput && toolVersionsPath) {
throw new Error(
"the `starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
"`starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
);
}

if (toolVersionsPath) {
let toolVersion = await getVersionFromToolVersionsFile(toolVersionsPath);

if (!toolVersion) {
throw new Error(
`failed to read Starknet Foundry version from: ${toolVersionsPath}`,
);
}
version = toolVersion;
}

if (!version) {
let toolVersion = await getVersionFromToolVersionsFile();
version = toolVersion ?? "latest";
}
let version = versionFromInput || versionFromFile || "latest";

if (version === "latest") {
version = await fetchLatestTag(repo);
}

if (version.startsWith("v")) {
version = version.substring(1);
}

return version;
return version.startsWith("v") ? version.slice(1) : version;
}

function fetchLatestTag(repo) {
Expand Down