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

Explicitly disable sparse checkout unless asked for #1598

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5adf77f
If no `sparse-checkout` parameter is specified, disable it
dscho Jan 31, 2024
c4cda12
npm run build
dscho Jan 31, 2024
6f108b2
ci: verify that an existing sparse checkout can be made unsparse
dscho Jan 31, 2024
6d74269
Prefer ubuntu over alpine in test-proxy workflow
jww3 Feb 16, 2024
4dfc3ce
revert change to container image in test.yml
jww3 Feb 16, 2024
463d088
Bump actions/checkout version in `test-proxy`
jww3 Feb 16, 2024
ed56252
prefer ununtu over alpine in `test-proxy`
jww3 Feb 16, 2024
268a122
Temporarily disable failing test.
jww3 Feb 16, 2024
b300d42
Inspect git version during `test-proxy`
jww3 Feb 16, 2024
9b4fb8b
fix order-of-operations in test.yml
jww3 Feb 16, 2024
9397c07
Fix order-of-operations in test.yml
jww3 Feb 16, 2024
3940af5
Ensure `test-proxy` is using an up-to-date version of git
jww3 Feb 16, 2024
572f5de
Experiment on `test-proxy`
jww3 Feb 16, 2024
78c6190
Create ubuntu-with-git.Dockerfile
jww3 Feb 16, 2024
a48123a
Rename ubuntu-with-git.Dockerfile to Dockerfile
jww3 Feb 17, 2024
34a3ecd
Create ubuntu-with-git/action.yml
jww3 Feb 17, 2024
6af92d2
Delete .github/ubuntu-with-git directory
jww3 Feb 17, 2024
894f97f
Removed commented-out docker commands in test.yml
jww3 Feb 17, 2024
996d145
Second attempt to install git via `apt-get`
jww3 Feb 17, 2024
87e9846
Followed official guidance for installing git
jww3 Feb 17, 2024
772739e
ensure `software-properties-common` is installed.
jww3 Feb 17, 2024
97826d9
Tweaked `apt` commands
jww3 Feb 17, 2024
eb87b7a
Tweaked `apt` commands
jww3 Feb 17, 2024
d5b8261
Upgrade `apt-get`
jww3 Feb 17, 2024
2349742
Try disabling `https_proxy` while git installs.
jww3 Feb 17, 2024
28a19e1
Update test.yml
jww3 Feb 17, 2024
82808ae
Update test.yml
jww3 Feb 17, 2024
365131c
Update test.yml
jww3 Feb 17, 2024
e7b6c8e
Update test.yml
jww3 Feb 17, 2024
9af61b0
Update test.yml
jww3 Feb 17, 2024
7aa0640
Determine path to git runtime
jww3 Feb 17, 2024
159fd98
Try mapping git runtime into container
jww3 Feb 17, 2024
5ecc8b5
Update test.yml
jww3 Feb 17, 2024
f0ae198
Update test.yml
jww3 Feb 17, 2024
bbd0474
Update test.yml
jww3 Feb 17, 2024
4d1347d
`test-proxy` now uses newly-minted `test-ubuntu-git` container image …
jww3 Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -7,6 +7,11 @@ on:
- main
- releases/*


# Note that when you see patterns like "ref: test-data/v2/basic" within this workflow,
# these refer to "test-data" branches on this actions/checkout repo.
# (For example, test-data/v2/basic -> https://github.com/actions/checkout/tree/test-data/v2/basic)

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -95,6 +100,16 @@ jobs:
- name: Verify sparse checkout
run: __test__/verify-sparse-checkout.sh

# Disabled sparse checkout in existing checkout
- name: Disabled sparse checkout
uses: ./
with:
path: sparse-checkout

- name: Verify disabled sparse checkout
shell: bash
run: set -x && ls -l sparse-checkout/src/git-command-manager.ts

# Sparse checkout (non-cone mode)
- name: Sparse checkout (non-cone mode)
uses: ./
Expand Down Expand Up @@ -175,7 +190,7 @@ jobs:
test-proxy:
runs-on: ubuntu-latest
container:
image: alpine/git:latest
image: ghcr.io/actions/test-ubuntu-git:main.20240221.114913.703z
options: --dns 127.0.0.1
services:
squid-proxy:
Expand Down Expand Up @@ -279,4 +294,4 @@ jobs:
- name: Fix Checkout v3
uses: actions/checkout@v3
with:
path: v3
path: v3
1 change: 1 addition & 0 deletions __test__/git-auth-helper.test.ts
Expand Up @@ -727,6 +727,7 @@ async function setup(testName: string): Promise<void> {
branchDelete: jest.fn(),
branchExists: jest.fn(),
branchList: jest.fn(),
disableSparseCheckout: jest.fn(),
sparseCheckout: jest.fn(),
sparseCheckoutNonConeMode: jest.fn(),
checkout: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions __test__/git-directory-helper.test.ts
Expand Up @@ -462,6 +462,7 @@ async function setup(testName: string): Promise<void> {
branchList: jest.fn(async () => {
return []
}),
disableSparseCheckout: jest.fn(),
sparseCheckout: jest.fn(),
sparseCheckoutNonConeMode: jest.fn(),
checkout: jest.fn(),
Expand Down
10 changes: 9 additions & 1 deletion dist/index.js
Expand Up @@ -576,6 +576,11 @@ class GitCommandManager {
return result;
});
}
disableSparseCheckout() {
return __awaiter(this, void 0, void 0, function* () {
yield this.execGit(['sparse-checkout', 'disable']);
});
}
sparseCheckout(sparseCheckout) {
return __awaiter(this, void 0, void 0, function* () {
yield this.execGit(['sparse-checkout', 'set', ...sparseCheckout]);
Expand Down Expand Up @@ -1282,7 +1287,10 @@ function getSource(settings) {
core.endGroup();
}
// Sparse checkout
if (settings.sparseCheckout) {
if (!settings.sparseCheckout) {
yield git.disableSparseCheckout();
}
else {
core.startGroup('Setting up sparse checkout');
Copy link
Contributor

@jww3 jww3 Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to pop the .startGroup / .endGroup calls outside of the if block?

Consider core.startGroup('Applying sparse checkout options');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because we're not actually setting up a sparse checkout. We're disabling it. But saying that would only make sense if there was a worktree already, otherwise there'd be no sparse checkout to disable.

if (settings.sparseCheckoutConeMode) {
yield git.sparseCheckout(settings.sparseCheckout);
Expand Down
5 changes: 5 additions & 0 deletions src/git-command-manager.ts
Expand Up @@ -17,6 +17,7 @@ export interface IGitCommandManager {
branchDelete(remote: boolean, branch: string): Promise<void>
branchExists(remote: boolean, pattern: string): Promise<boolean>
branchList(remote: boolean): Promise<string[]>
disableSparseCheckout(): Promise<void>
sparseCheckout(sparseCheckout: string[]): Promise<void>
sparseCheckoutNonConeMode(sparseCheckout: string[]): Promise<void>
checkout(ref: string, startPoint: string): Promise<void>
Expand Down Expand Up @@ -171,6 +172,10 @@ class GitCommandManager {
return result
}

async disableSparseCheckout(): Promise<void> {
await this.execGit(['sparse-checkout', 'disable'])
}

async sparseCheckout(sparseCheckout: string[]): Promise<void> {
await this.execGit(['sparse-checkout', 'set', ...sparseCheckout])
}
Expand Down
4 changes: 3 additions & 1 deletion src/git-source-provider.ts
Expand Up @@ -208,7 +208,9 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
}

// Sparse checkout
if (settings.sparseCheckout) {
if (!settings.sparseCheckout) {
await git.disableSparseCheckout()
} else {
core.startGroup('Setting up sparse checkout')
if (settings.sparseCheckoutConeMode) {
await git.sparseCheckout(settings.sparseCheckout)
Expand Down