Skip to content

Commit c040601

Browse files
committed
ci: extract verifying line endings into a script
1 parent f61fbca commit c040601

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

src/ci/azure-pipelines/steps/run.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,33 +126,17 @@ steps:
126126
displayName: Disable git automatic line ending conversion
127127
condition: and(succeeded(), not(variables.SKIP_JOB))
128128

129-
# Check out all our submodules, but more quickly than using git by using one of
130-
# our custom scripts
131129
- bash: src/ci/scripts/checkout-submodules.sh
132130
env:
133131
AGENT_OS: $(Agent.OS)
134132
displayName: Checkout submodules
135133
condition: and(succeeded(), not(variables.SKIP_JOB))
136134

137-
# See also the disable for autocrlf above, this just checks that it worked
138-
#
139-
# We check both in rust-lang/rust and in a submodule to make sure both are
140-
# accurate. Submodules are checked out significantly later than the main
141-
# repository in this script, so settings can (and do!) change between then.
142-
#
143-
# Linux (and maybe macOS) builders don't currently have dos2unix so just only
144-
# run this step on Windows.
145-
- bash: |
146-
set -x
147-
# print out the git configuration so we can better investigate failures in
148-
# the following
149-
git config --list --show-origin
150-
dos2unix -ih Cargo.lock src/tools/rust-installer/install-template.sh
151-
endings=$(dos2unix -ic Cargo.lock src/tools/rust-installer/install-template.sh)
152-
# if endings has non-zero length, error out
153-
if [ -n "$endings" ]; then exit 1 ; fi
154-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
155-
displayName: Verify line endings are LF
135+
- bash: src/ci/scripts/verify-line-endings.sh
136+
env:
137+
AGENT_OS: $(Agent.OS)
138+
displayName: Verify line endings
139+
condition: and(succeeded(), not(variables.SKIP_JOB))
156140

157141
# Ensure the `aws` CLI is installed so we can deploy later on, cache docker
158142
# images, etc.

src/ci/scripts/verify-line-endings.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# See also the disable for autocrlf, this just checks that it worked.
3+
#
4+
# We check both in rust-lang/rust and in a submodule to make sure both are
5+
# accurate. Submodules are checked out significantly later than the main
6+
# repository in this script, so settings can (and do!) change between then.
7+
#
8+
# Linux (and maybe macOS) builders don't currently have dos2unix so just only
9+
# run this step on Windows.
10+
11+
set -euo pipefail
12+
IFS=$'\n\t'
13+
14+
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
15+
16+
if isWindows; then
17+
# print out the git configuration so we can better investigate failures in
18+
# the following
19+
git config --list --show-origin
20+
dos2unix -ih Cargo.lock src/tools/rust-installer/install-template.sh
21+
endings=$(dos2unix -ic Cargo.lock src/tools/rust-installer/install-template.sh)
22+
# if endings has non-zero length, error out
23+
if [ -n "$endings" ]; then exit 1 ; fi
24+
fi

0 commit comments

Comments
 (0)