Skip to content

Commit f3524e9

Browse files
authored
Hashpin sensitive dependencies and configure dependabot to update them automatically (#75859)
Closes #75620 As I mentioned on the issue, this PR aims to hash-pin the CI dependencies used on sensitive context -- i.e., they either are called with write permissions, or are being used to build critical artifacts like a release. In summary, this PR brings 3 changes: 1. Hash pin GitHub Actions called on sensitive context 2. Hash pin python dependencies used on sensitive context 3. Configure dependabot to automatically update those hashes I'm further explaining the steps bellow. The dependencies in format of GitHub Actions, I simply hash-pinned them. I also made sure to keep the human-readable version as comments at the same line. At the [release-tasks.yml](https://github.com/llvm/llvm-project/blob/main/.github/workflows/release-tasks.yml) file, I've changed the installation method of some python dependencies to install them considering their hashpinning. That required the generation of a requirements file that had all the correct hashes, and for that I used [pip-tools](https://pypi.org/project/pip-tools/2.0.0/). While configuring dependabot, I set it to send a monthly PR updating all the GitHub Actions, and a weekly PR to update any python dependency required by [/llvm/docs/requirements.txt](https://github.com/llvm/llvm-project/blob/main/llvm/docs/requirements.txt). Let me know if you have any questions or concerns, I'd be happy to clarify and help. Thanks! --------- Signed-off-by: Diogo Teles Sant'Anna <[email protected]>
1 parent 9fdd25e commit f3524e9

File tree

4 files changed

+398
-14
lines changed

4 files changed

+398
-14
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"
11+
- package-ecosystem: "pip"
12+
directory: "/llvm/docs"
13+
schedule:
14+
interval: "monthly"
15+
groups:
16+
llvm-docs-requirements:
17+
patterns:
18+
- "*"

.github/workflows/release-binaries.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
steps:
3939
- name: Checkout LLVM
40-
uses: actions/checkout@v4
40+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4141

4242
- name: Validate and parse tag
4343
id: validate-tag
@@ -77,15 +77,15 @@ jobs:
7777
- ubuntu-22.04
7878
steps:
7979
- name: Checkout LLVM
80-
uses: actions/checkout@v4
80+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
8181
with:
8282
ref: ${{ needs.prepare.outputs.ref }}
8383

8484
- name: Install Ninja
85-
uses: llvm/actions/install-ninja@main
85+
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
8686

8787
- name: Setup sccache
88-
uses: hendrikmuhs/ccache-action@v1
88+
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
8989
with:
9090
max-size: 250M
9191
key: sccache-${{ matrix.os }}-release
@@ -119,13 +119,13 @@ jobs:
119119
120120
steps:
121121
- name: Checkout LLVM
122-
uses: actions/checkout@v4
122+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
123123
with:
124124
ref: ${{ needs.prepare.outputs.ref }}
125125
path: ${{ needs.prepare.outputs.build-dir }}/llvm-project
126126

127127
- name: Setup sccache
128-
uses: hendrikmuhs/ccache-action@v1
128+
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
129129
with:
130130
max-size: 250M
131131
key: sccache-${{ matrix.target.os }}-release

.github/workflows/release-tasks.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
echo "release-version=$release_version" >> "$GITHUB_OUTPUT"
2626
2727
- name: Checkout LLVM
28-
uses: actions/checkout@v4
28+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2929

3030
- name: Install Dependencies
3131
run: |
@@ -36,7 +36,7 @@ jobs:
3636
python3-github \
3737
ninja-build \
3838
texlive-font-utils
39-
pip3 install --user -r ./llvm/docs/requirements.txt
39+
pip3 install --user --require-hashes -r ./llvm/docs/requirements-hashed.txt
4040
4141
- name: Create Release
4242
run: |
@@ -48,14 +48,14 @@ jobs:
4848
./llvm/utils/release/github-upload-release.py --token ${{ github.token }} --release ${{ steps.validate-tag.outputs.release-version }} upload --files ./*doxygen*.tar.xz
4949
5050
- name: Create Release Notes Artifact
51-
uses: actions/upload-artifact@v3
51+
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
5252
with:
5353
name: release-notes
5454
path: docs-build/html-export/
5555

5656
- name: Clone www-releases
5757
if: ${{ !contains(steps.validate-tag.outputs.release-version, 'rc') }}
58-
uses: actions/checkout@v4
58+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5959
with:
6060
repository: ${{ github.repository_owner }}/www-releases
6161
ref: main
@@ -79,10 +79,10 @@ jobs:
7979
if: github.repository == 'llvm/llvm-project'
8080
steps:
8181
- name: Checkout LLVM
82-
uses: actions/checkout@v4
82+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
8383

8484
- name: Setup Cpp
85-
uses: aminya/setup-cpp@v1
85+
uses: aminya/setup-cpp@6e563b8e5f796db317104d19605a414345807897 # v1
8686
with:
8787
compiler: llvm-16.0.6
8888
cmake: true
@@ -108,14 +108,14 @@ jobs:
108108
python3 setup.py sdist
109109
110110
- name: Upload lit to test.pypi.org
111-
uses: pypa/gh-action-pypi-publish@release/v1
111+
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # release/v1
112112
with:
113113
password: ${{ secrets.LLVM_LIT_TEST_PYPI_API_TOKEN }}
114114
repository-url: https://test.pypi.org/legacy/
115115
packages-dir: llvm/utils/lit/dist/
116116

117117
- name: Upload lit to pypi.org
118-
uses: pypa/gh-action-pypi-publish@release/v1
118+
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf # release/v1
119119
with:
120120
password: ${{ secrets.LLVM_LIT_PYPI_API_TOKEN }}
121121
packages-dir: llvm/utils/lit/dist/

0 commit comments

Comments
 (0)