Skip to content

Commit

Permalink
fix rust lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
tateexon committed May 9, 2024
1 parent 847c9b3 commit 004c598
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 28 deletions.
8 changes: 1 addition & 7 deletions .github/actions/build_contract_artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ runs:
# start container
docker run -d -v $(pwd):/repo --name build-container "${image}":"${image_version}" tail -f /dev/null
# generate go bindings
docker exec build-container bash -c "\
chown -R $(id -u):$(id -g) /repo &&\
/repo/scripts/build-contract-artifacts-action.sh"
docker exec build-container bash -c "/repo/scripts/build-contract-artifacts-action.sh"
# check go bindings
git diff --stat --exit-code
# build with keys
Expand All @@ -47,10 +45,6 @@ runs:
# clean up the container
docker stop build-container
docker rm build-container
# fix upload permissions
# chown -R $(whoami):$(whoami) ./contracts/target/deploy/
# chmod -R 644 ./contracts/target/deploy/
# should be used again after moving from projectserum/build to backpackapp/build
- name: Install latest Git version (>= 2.18.0) for actions/checkout
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/contract-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ jobs:
- name: Build Artifacts
env:
psversion: ${{ needs.get_projectserum_version.outputs.projectserum_version }}
run: docker run -v $(pwd):/repo projectserum/build:"${psversion}"" bash -c "anchor build"
run: |

Check failure on line 36 in .github/workflows/contract-release.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/contract-release.yml#L36

shellcheck reported issue in this script: SC2046:warning:1:15: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/contract-release.yml:36:9: shellcheck reported issue in this script: SC2046:warning:1:15: Quote this to prevent word splitting [shellcheck]
docker run -v $(pwd):/repo projectserum/build:"${psversion}" bash -c "\
anchor build &&\
chown -R $(id -u):$(id -g) /repo"
- name: Generate archive
run: |
tar cfvz artifacts.tar.gz target/deploy/*.so target/idl/*
Expand Down
84 changes: 64 additions & 20 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
runs-on: ubuntu-latest
needs: [get_projectserum_version]
container:
image: projectserum/build:${{ needs.get_projectserum_version.outputs.projectserum_version }}
env:
RUSTUP_HOME: "/root/.rustup"
FORCE_COLOR: 1
# image: projectserum/build:${{ needs.get_projectserum_version.outputs.projectserum_version }}
# env:
# RUSTUP_HOME: "/root/.rustup"
# FORCE_COLOR: 1

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
Expand All @@ -52,28 +52,65 @@ jobs:
path: contracts/target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- run: solana-keygen new -o id.json --no-bip39-passphrase
- run: |

Check failure on line 55 in .github/workflows/rust.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/rust.yml#L55

shellcheck reported issue in this script: SC2046:warning:1:18: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/rust.yml:55:7: shellcheck reported issue in this script: SC2046:warning:1:18: Quote this to prevent word splitting [shellcheck]

Check failure on line 55 in .github/workflows/rust.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/rust.yml#L55

shellcheck reported issue in this script: SC2140:warning:3:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
Raw output
.github/workflows/rust.yml:55:7: shellcheck reported issue in this script: SC2140:warning:3:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
docker run -d -v $(pwd)/../:/repo --name build-container projectserum/build:"${psversion}" tail -f /dev/null
docker exec build-container bash -c "\
RUSTUP_HOME="/root/.rustup" &&\
FORCE_COLOR=1 &&\
solana-keygen new -o id.json --no-bip39-passphrase"
- name: Compile typescript client
run: |
cd ../ts
yarn install --frozen-lockfile
yarn build
- run: yarn install --frozen-lockfile
- run: anchor test
- run: |
cd examples/hello-world
yarn install --frozen-lockfile
anchor test
docker exec build-container bash -c "\
RUSTUP_HOME="/root/.rustup" &&\
FORCE_COLOR=1 &&\
cd /repo/ts &&\
yarn install --frozen-lockfile &&\
yarn build"
- name: anchor test contracts
run: |

Check failure on line 70 in .github/workflows/rust.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/rust.yml#L70

shellcheck reported issue in this script: SC2140:warning:2:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
Raw output
.github/workflows/rust.yml:70:7: shellcheck reported issue in this script: SC2140:warning:2:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
docker exec build-container bash -c "\
RUSTUP_HOME="/root/.rustup" &&\
FORCE_COLOR=1 &&\
cd /repo/contracts &&\
yarn install --frozen-lockfile &&\
anchor test"
- name: anchor test hello-world
run: |

Check failure on line 78 in .github/workflows/rust.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/rust.yml#L78

shellcheck reported issue in this script: SC2140:warning:2:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
Raw output
.github/workflows/rust.yml:78:7: shellcheck reported issue in this script: SC2140:warning:2:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
docker exec build-container bash -c "\
RUSTUP_HOME="/root/.rustup" &&\
FORCE_COLOR=1 &&\
cd /repo/examples/hello-world &&\
yarn install --frozen-lockfile &&\
anchor test"
# clean up the container
docker stop build-container
docker rm build-container
# - run: solana-keygen new -o id.json --no-bip39-passphrase
# - name: Compile typescript client
# run: |
# cd ../ts
# yarn install --frozen-lockfile
# yarn build
# - name: anchor test contracts
# run: |
# yarn install --frozen-lockfile
# anchor test
# - name: anchor test hello-world
# run: |
# cd examples/hello-world
# yarn install --frozen-lockfile
# anchor test

rust_lint:
name: Rust Lint
runs-on: ubuntu-latest
needs: [get_projectserum_version]
container:
image: projectserum/build:${{ needs.get_projectserum_version.outputs.projectserum_version }}
env:
RUSTUP_HOME: "/root/.rustup"
FORCE_COLOR: 1
# image: projectserum/build:${{ needs.get_projectserum_version.outputs.projectserum_version }}
# env:
# RUSTUP_HOME: "/root/.rustup"
# FORCE_COLOR: 1

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
Expand All @@ -95,5 +132,12 @@ jobs:
path: contracts/target
key: ${{ runner.os }}-v2-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- run: cargo check
- run: cargo clippy -- -D warnings
- run: |

Check failure on line 135 in .github/workflows/rust.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/rust.yml#L135

shellcheck reported issue in this script: SC2046:warning:1:15: Quote this to prevent word splitting [shellcheck]
Raw output
.github/workflows/rust.yml:135:7: shellcheck reported issue in this script: SC2046:warning:1:15: Quote this to prevent word splitting [shellcheck]

Check failure on line 135 in .github/workflows/rust.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/rust.yml#L135

shellcheck reported issue in this script: SC2140:warning:2:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
Raw output
.github/workflows/rust.yml:135:7: shellcheck reported issue in this script: SC2140:warning:2:16: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? [shellcheck]
docker run -v $(pwd):/repo projectserum/build:"${psversion}" bash -c "\
RUSTUP_HOME="/root/.rustup" &&\
FORCE_COLOR=1 &&\
cargo check &&\
cargo clippy -- -D warnings"
# - run: cargo check
# - run: cargo clippy -- -D warnings

0 comments on commit 004c598

Please sign in to comment.