summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/rust-unused-dependencies.yml
blob: d11fa6fa23c73a8e82c51a5fc835f790c80c0a28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
name: Rust - Unused dependencies
on:
  pull_request:
    paths:
      - .github/workflows/rust-unused-dependencies.yml
      - '**/*.rs'
      - '**/Cargo.toml'
      - 'building/*-container-image.txt'
  workflow_dispatch:
env:
  # Pinning nightly just to avoid random breakage. It's fine to bump this at any time
  RUST_NIGHTLY_TOOLCHAIN: nightly-2025-05-14

permissions: {}

jobs:
  prepare-containers:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Fetch container image names
        run: |
          echo "inner_container_image_linux=$(cat ./building/linux-container-image.txt)" >> $GITHUB_ENV
          echo "inner_container_image_android=$(cat ./building/android-container-image.txt)" >> $GITHUB_ENV

    outputs:
      container_image_linux: ${{ env.inner_container_image_linux }}
      container_image_android: ${{ env.inner_container_image_android }}

  cargo-udeps-linux:
    needs: prepare-containers
    runs-on: ubuntu-latest
    container:
      image: ${{ needs.prepare-containers.outputs.container_image_linux }}

    steps:
      # Fix for HOME path overridden by GH runners when building in containers, see:
      # https://github.com/actions/runner/issues/863
      - name: Fix HOME path
        run: echo "HOME=/root" >> $GITHUB_ENV

      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Checkout submodules
        run: |
          git config --global --add safe.directory '*'
          git submodule update --init --depth=1 dist-assets/binaries
          git submodule update --init wireguard-go-rs/libwg/wireguard-go

      - name: Install nightly Rust toolchain
        run: rustup override set $RUST_NIGHTLY_TOOLCHAIN

      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-udeps

      - name: Check for unused dependencies
        shell: bash
        run: cargo udeps --workspace

  cargo-udeps-android:
    needs: prepare-containers
    runs-on: ubuntu-latest
    container:
      image: ${{ needs.prepare-containers.outputs.container_image_android }}

    steps:
      # Fix for HOME path overridden by GH runners when building in containers, see:
      # https://github.com/actions/runner/issues/863
      - name: Fix HOME path
        run: echo "HOME=/root" >> $GITHUB_ENV

      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Checkout wireguard-go submodule
        run: |
          git config --global --add safe.directory '*'
          git submodule update --init wireguard-go-rs/libwg/wireguard-go

      - name: Install nightly Rust
        run: |
          rustup override set ${{ env.RUST_NIGHTLY_TOOLCHAIN }}
          rustup target add aarch64-linux-android

      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-udeps

      - name: Check for unused dependencies
        run: cargo udeps --target aarch64-linux-android --package mullvad-jni

  cargo-udeps:
    strategy:
      matrix:
        os: [windows-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      # By default, the longest path a filename can have in git on Windows is 260 character.
      - name: Set git config for long paths
        if: runner.os == 'Windows'
        run: |
          git config --system core.longpaths true

      - name: Checkout repository
        uses: actions/checkout@v4

      - uses: ./.github/actions/mullvad-build-env
        with:
          rust-toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }}

      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-udeps

      - name: Check for unused dependencies
        shell: bash
        run: cargo udeps --workspace