Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 fails on library crates with no Cargo.lock file #27

Closed
wookietreiber opened this issue Oct 7, 2024 · 3 comments
Closed

v2 fails on library crates with no Cargo.lock file #27

wookietreiber opened this issue Oct 7, 2024 · 3 comments

Comments

@wookietreiber
Copy link

In v2, if there is no Cargo.lock in the repository, as is pretty much normal with library crates, the action fails because v2 no longer runs cargo generate-lockfile.

Can cargo generate-lockfile be conditionally run if there is no Cargo.lock in the repository, as opposed to running it always and potentially overwriting an existing Cargo.lock?

@tarcieri
Copy link
Member

tarcieri commented Oct 7, 2024

This was deliberately removed in #15

@tarcieri tarcieri closed this as completed Oct 7, 2024
@wookietreiber
Copy link
Author

This was deliberately removed in #15

Yes, I know, but note that for library packages, that don't include a Cargo.lock in the repository, I now have to manually generate the Cargo.lock:

diff --git a/.github/workflows/rust-audit-scheduled.yml b/.github/workflows/rust-audit-scheduled.yml
index 033f1b1..fa92930 100644
--- a/.github/workflows/rust-audit-scheduled.yml
+++ b/.github/workflows/rust-audit-scheduled.yml
@@ -11,7 +11,9 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: rustsec/audit-check@v1.4.1
+      - name: generate Cargo.lock
+        run: cargo generate-lockfile
+      - uses: rustsec/audit-check@v2.0.0
         with:
           token: ${{ secrets.GITHUB_TOKEN }}

diff --git a/.github/workflows/rust-audit.yml b/.github/workflows/rust-audit.yml
index 30a1d4c..425def4 100644
--- a/.github/workflows/rust-audit.yml
+++ b/.github/workflows/rust-audit.yml
@@ -18,7 +18,9 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: rustsec/audit-check@v1.4.1
+      - name: generate Cargo.lock
+        run: cargo generate-lockfile
+      - uses: rustsec/audit-check@v2.0.0
         with:
           token: ${{ secrets.GITHUB_TOKEN }}

This is why I was asking if it could be generated conditionally based on existence of Cargo.lock.

@tarcieri
Copy link
Member

We used to do that and it was also deliberately removed: rustsec/rustsec#1112

If you know you need to unconditionally generate a Cargo.lock, perhaps in your workflow you can run cargo generate-lockfile yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants