Skip to content

Commit

Permalink
handle windows file separator in filesets (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored Dec 6, 2024
1 parent 9a4403d commit 3dfd9ac
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-eagles-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vscode-apollo": patch
---

Fix a bug handling windows path separators in `FileSet` instances.
45 changes: 41 additions & 4 deletions .github/workflows/E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,63 @@ on:
jobs:
test:
name: Run E2E tests
runs-on: ubuntu-latest
runs-on: "${{ matrix.os }}"
strategy:
matrix:
version: ["1.90.0", "stable", "insiders"]
os: [ubuntu-latest]
include:
- version: "stable"
os: "windows-latest"
steps:
- run: sudo apt update && sudo apt install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb expect
if: runner.os == 'Linux'
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: "npm"
- run: npm install
- run: npm run build:production
- run: echo 'APOLLO_KEY="service:bob-123:489fhseo4"' > ./sampleWorkspace/spotifyGraph/.env
- run: |
shell: bash
- name: Install & Configure Rover (Linux)
run: |
expect <<EOF
spawn ./node_modules/.bin/rover config auth --profile VSCode-E2E
expect "Copy the key and paste it into the prompt below."
send -- "test\n"
expect eof
EOF
- run: xvfb-run -a npm run test:extension
if: runner.os == 'Linux'
- name: Install Rover (Windows)
run: ./node_modules/.bin/rover.cmd --version
if: runner.os == 'Windows'
- name: Configure Rover (Windows)
run: |
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Start-Process -FilePath ./node_modules/.bin/rover.cmd -ArgumentList "config","auth","--profile","VSCode-E2E"
Start-Sleep -m 1000
[System.Windows.Forms.SendKeys]::SendWait("test")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
if: runner.os == 'Windows'
shell: powershell
- name: Adjust configuration (Windows)
run: |
sed -i -e 's/\(bin:.*\)/\1.exe/' sampleWorkspace/rover/apollo.config.yaml
cat sampleWorkspace/rover/apollo.config.yaml
# for some reason, windows seems to ignore the jest.e2e.config.js file
echo "module.exports = require('./jest.e2e.config')" > jest.config.ts
shell: bash
if: runner.os == 'Windows'
- run: npm run build:production
- name: "Run Extension E2E tests (Linux)"
run: xvfb-run -a npm run test:extension
env:
VSCODE_VERSION: "${{ matrix.version }}"
if: runner.os == 'Linux'
- name: "Run Extension E2E tests (Windows)"
run: npm run test:extension
env:
VSCODE_VERSION: "${{ matrix.version }}"
if: runner.os == 'Windows'
5 changes: 5 additions & 0 deletions src/language-server/__e2e__/rover.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ if (test === origTest.skip) {
);
}

if (process.platform === "win32") {
console.info("Skipping rover E2E tests in Windows");
test = origTest.skip;
}

let editor: TextEditor;
let getPosition: GetPositionFn;
beforeAll(async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/language-server/__e2e__/studioGraph.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ test("wrong token", async () => {

// currently, this logs twice, along with a full stracktrace, but no indication of where it came from
// this should be improved on.
expect(output).toContain(
expect(output.replace(/\s/g, "")).toContain(
`
[GraphQL error]: HTTP fetch failed from 'kotlin': 406: Not Acceptable
[GraphQL error]: Invalid credentials provided
ApolloError: HTTP fetch failed from 'kotlin': 406: Not Acceptable
Invalid credentials provided
at new ApolloError`.trim(),
at new ApolloError`.replace(/\s/g, ""),
);
} finally {
await mocks.loadDefaultMocks(baseUri);
Expand Down
6 changes: 3 additions & 3 deletions src/language-server/fileSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { minimatch } from "minimatch";
import { globSync } from "glob";
import { invariant } from "../tools";
import { URI } from "vscode-uri";
import { normalizeURI } from "./utilities";
import { normalizeURI, withUnixSeparator } from "./utilities";
import { resolve } from "path";

export class FileSet {
Expand Down Expand Up @@ -35,13 +35,13 @@ export class FileSet {
this.includes.some((include) => {
return minimatch(
normalizedFilePath,
resolve(this.rootURI.fsPath, include),
withUnixSeparator(resolve(this.rootURI.fsPath, include)),
);
}) &&
!this.excludes.some((exclude) => {
return minimatch(
normalizedFilePath,
resolve(this.rootURI.fsPath, exclude),
withUnixSeparator(resolve(this.rootURI.fsPath, exclude)),
);
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/language-server/utilities/uri.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { URI } from "vscode-uri";

const withUnixSeparator = (uriString: string) =>
export const withUnixSeparator = (uriString: string) =>
uriString.split(/[\/\\]/).join("/");

export const normalizeURI = (uriString: string) => {
Expand Down

0 comments on commit 3dfd9ac

Please sign in to comment.