Skip to content

Commit 6ea8daa

Browse files
authored
fix(rosetta): OOpsie -- couldn't find root file back on Windows (#1842)
The root file was located by comparing file paths in a way that was not adjusting path separators for Windows, and the result was inability to match normalized paths with Unix-style ones. This normalizes paths before attempting to match them, so that the match can succeed. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
1 parent 119d703 commit 6ea8daa

10 files changed

Lines changed: 73 additions & 28 deletions

File tree

.github/workflows/main.yml

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
env:
1111
DOTNET_NOLOGO: true
1212

13+
# This workflows currently has the following jobs:
14+
# - build : Builds the source tree as-is
15+
# - test : Runs all unit tests against the build result
16+
# - create-release-package : Prepares a release package with the "real" version
17+
1318
jobs:
1419
build:
1520
name: Build
@@ -32,13 +37,8 @@ jobs:
3237
uses: actions/setup-python@v2
3338
with:
3439
python-version: '3.6'
35-
- name: 'Linux: Install python3-venv'
36-
if: runner.os == 'Linux'
40+
- name: Install python3-venv
3741
run: sudo apt install -y python3-venv
38-
- name: 'Windows: Expose python3 command'
39-
if: runner.os == 'Windows'
40-
shell: bash
41-
run: cp ${pythonLocation}/python.exe ${pythonLocation}/python3.exe
4242
- name: Check out
4343
uses: actions/checkout@v2
4444
- name: Locate Caches
@@ -75,6 +75,55 @@ jobs:
7575
!**/.env/**
7676
!**/node_modules/**
7777
!**/project/.m2/**
78+
79+
create-release-package:
80+
name: Create Release Package
81+
runs-on: ubuntu-latest
82+
steps:
83+
# Set up all of our standard runtimes
84+
- name: Set up .NET 3.1
85+
uses: actions/setup-dotnet@v1
86+
with:
87+
dotnet-version: '3.1.x'
88+
- name: Set up Java 8
89+
uses: actions/setup-java@v1
90+
with:
91+
java-version: '8'
92+
- name: Set up Node 12
93+
uses: actions/setup-node@v2.1.1
94+
with:
95+
node-version: '12'
96+
- name: Set up Python 3.6
97+
uses: actions/setup-python@v2
98+
with:
99+
python-version: '3.6'
100+
- name: Install python3-venv
101+
run: sudo apt install -y python3-venv
102+
- name: Check out
103+
uses: actions/checkout@v2
104+
- name: Locate Caches
105+
id: cache-locations
106+
run: |-
107+
# Need to have PIP >= 20.1 for "pip cache dir" to work
108+
python3 -m pip install --upgrade pip
109+
echo "::set-output name=pip-cache::$(python3 -m pip cache dir)"
110+
echo "::set-output name=yarn-cache::$(yarn cache dir)"
111+
- name: Cache
112+
uses: actions/cache@v2
113+
with:
114+
path: |-
115+
${{ steps.cache-locations.outputs.pip-cache }}
116+
${{ steps.cache-locations.outputs.yarn-cache }}
117+
~/.m2/repository
118+
~/.nuget/packages
119+
key: ${{ runner.os }}-node@12-python@3.6-${{ hashFiles('**/yarn.lock') }}
120+
restore-keys: |-
121+
${{ runner.os }}-node@12-python@3.6-
122+
${{ runner.os }}-node@12-
123+
${{ runner.os }}-
124+
# Prepare dependencies and build
125+
- name: Install Dependencies
126+
run: yarn install --frozen-lockfile
78127
# Determine a prerelease version (depending on whether this is a PR or Push event)
79128
- name: Standard Version (PR)
80129
if: github.event_name == 'pull_request'
@@ -93,7 +142,7 @@ jobs:
93142
# Now we'll be preparing a release package (with the "real" version)
94143
- name: Align Versions
95144
run: ./scripts/align-version.sh
96-
- name: Rebuild
145+
- name: Full Build
97146
run: yarn build
98147
- name: Package Libraries
99148
run: yarn package
@@ -102,7 +151,6 @@ jobs:
102151
with:
103152
name: release-package
104153
path: ${{ github.workspace }}/dist/
105-
106154
test:
107155
name: Test (${{ matrix.os }} / java ${{ matrix.java }} / node ${{ matrix.node }} / python ${{ matrix.python }})
108156
needs: build

packages/@jsii/dotnet-runtime-test/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"main": "lib/index.js",
2525
"types": "lib/index.d.ts",
2626
"scripts": {
27-
"gen": "/bin/bash ./generate.sh",
28-
"build": "npm run gen && tsc --build && /bin/bash ./build.sh",
29-
"test": "/bin/bash ./test.sh",
27+
"gen": "bash ./generate.sh",
28+
"build": "npm run gen && tsc --build && bash ./build.sh",
29+
"test": "bash ./test.sh",
3030
"test:update": "UPDATE_DIFF=1 npm run test"
3131
},
3232
"devDependencies": {

packages/@jsii/dotnet-runtime/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
"main": "lib/index.js",
3131
"types": "lib/index.d.ts",
3232
"scripts": {
33-
"gen": "/bin/bash ./generate.sh",
34-
"build": "npm run gen && tsc --build && /bin/bash ./build.sh",
33+
"gen": "bash ./generate.sh",
34+
"build": "npm run gen && tsc --build && bash ./build.sh",
3535
"dist-clean": "rm -rf dist && dotnet clean -c Release ./src/Amazon.JSII.Runtime.sln",
36-
"test": "/bin/bash ./test.sh",
36+
"test": "bash ./test.sh",
3737
"test:update": "UPDATE_DIFF=1 npm run test",
3838
"package": "package-dotnet ./src/Amazon.JSII.Runtime.sln && package-private"
3939
},

packages/@jsii/java-runtime-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"main": "lib/index.js",
2424
"types": "lib/index.d.ts",
2525
"scripts": {
26-
"build": "/bin/bash ./generate.sh",
26+
"build": "bash ./generate.sh",
2727
"test": "node ./user.xml.t.js > ./project/user.xml && cd project && mvn -B test --settings=user.xml",
2828
"test:update": "UPDATE_DIFF=1 npm run test"
2929
},

packages/@jsii/java-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"main": "lib/index.js",
2525
"types": "lib/index.d.ts",
2626
"scripts": {
27-
"gen": "/bin/bash ./generate.sh",
27+
"gen": "bash ./generate.sh",
2828
"build": "tsc --build && npm run gen && cd project && mvn -B deploy -D altDeploymentRepository=local::default::file://${PWD}/../maven-repo --settings=user.xml",
2929
"dist-clean": "rm -rf dist maven-repo && cd project && mvn -B clean --settings=user.xml",
3030
"test": "echo 'Tests are run as part of the build target'",

packages/@jsii/runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"jsii-runtime": "bin/jsii-runtime"
2626
},
2727
"scripts": {
28-
"build": "tsc --build && chmod +x bin/jsii-runtime && /bin/bash ./bundle.sh && npm run lint",
28+
"build": "tsc --build && chmod +x bin/jsii-runtime && bash ./bundle.sh && npm run lint",
2929
"watch": "tsc --build -w",
3030
"lint": "eslint . --ext .js,.ts --ignore-path=.gitignore --ignore-pattern=webpack.config.js",
3131
"lint:fix": "yarn lint --fix",

packages/jsii-pacmak/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
"jsii-pacmak": "bin/jsii-pacmak"
2626
},
2727
"scripts": {
28-
"gen": "/bin/bash generate.sh",
28+
"gen": "bash generate.sh",
2929
"build": "npm run gen && tsc --build && chmod +x bin/jsii-pacmak && npm run lint",
3030
"watch": "tsc --build -w",
3131
"lint": "eslint . --ext .js,.ts --ignore-path=.gitignore",
3232
"lint:fix": "yarn lint --fix",
33-
"test": "jest && /bin/bash test/diff-test.sh && /bin/bash test/build-test.sh",
34-
"test:update": "UPDATE_DIFF=1 /bin/bash test/diff-test.sh && /bin/bash test/build-test.sh && jest -u",
33+
"test": "jest && bash test/diff-test.sh && bash test/build-test.sh",
34+
"test:update": "UPDATE_DIFF=1 bash test/diff-test.sh && bash test/build-test.sh && jest -u",
3535
"package": "package-js"
3636
},
3737
"dependencies": {

packages/jsii-rosetta/lib/typescript/ts-compiler.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,10 @@ export class TypeScriptCompiler {
7373
),
7474
});
7575

76-
const rootFiles = program
77-
.getSourceFiles()
78-
.filter((f) => f.fileName === filename);
79-
if (rootFiles.length === 0) {
76+
const rootFile = program.getSourceFile(filename);
77+
if (rootFile == null) {
8078
throw new Error("Oopsie -- couldn't find root file back");
8179
}
82-
const rootFile = rootFiles[0];
8380

8481
return { program, rootFile };
8582
}

packages/jsii-rosetta/test/jsii/assemblies.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ test('Backwards compatibility with literate integ tests', () => {
146146
expect(snippets[0].completeSource).toEqual('# Some literate source file');
147147
expect(
148148
snippets[0]?.parameters?.[SnippetParameters.$COMPILATION_DIRECTORY],
149-
).toEqual('/package/test');
149+
).toEqual(path.normalize('/package/test'));
150150
} finally {
151151
mockfs.restore();
152152
}

packages/jsii-rosetta/test/translations.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ function makeTests() {
7575
});
7676
afterAll(() => {
7777
// Print the AST for tests that failed (to help debugging)
78-
if (anyFailed) {
78+
if (anyFailed && translator) {
7979
const vis = translator.renderUsing(new VisualizeAstVisitor(true));
8080
console.log(`${vis}\n`);
8181
}
82-
(translator as any) = undefined; // Need this to properly release memory
82+
translator = undefined as any; // Need this to properly release memory
8383
});
8484

8585
SUPPORTED_LANGUAGES.forEach((supportedLanguage) => {

0 commit comments

Comments
 (0)