Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
"@typescript-eslint/unbound-method": "error",
"import/no-unresolved": ["error", { "ignore": ["@octokit/core", "@octokit/plugin-rest-endpoint-methods"] }]
Copy link
Owner

Choose a reason for hiding this comment

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

@copilot why this change is necessary for this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ESLint rule change is necessary because the new @octokit/core and @octokit/plugin-rest-endpoint-methods packages are ES modules (they have "type": "module" in their package.json), which causes ESLint's import/no-unresolved rule to fail to resolve their imports. Without this ignore rule, ESLint throws errors like "Unable to resolve path to module '@octokit/core'". The rule specifically ignores these two packages while maintaining import resolution checking for all other dependencies. Commit: 53879e5

},
"env": {
"node": true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ Or set a `GITHUB_TOKEN` environment variable, to use the latest released version
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

The 'latest release' here means [the most recent non-prerelease, non-draft release, sorted by the created_at attribute](https://octokit.github.io/rest.js/v19#repos-get-latest-release).
The 'latest release' here means [the most recent non-prerelease, non-draft release, sorted by the created_at attribute](https://docs.github.com/en/rest/releases/releases#get-the-latest-release).

Note that the `GITHUB_TOKEN` should have [`contents: read` permission](https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#contents) to fetch data from the GitHub.com.
24 changes: 24 additions & 0 deletions __tests__/__mocks__/@octokit/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
Octokit: class MockOctokit {
constructor(options) {
this.options = options;
}

static plugin(plugin) {
return class PluggedOctokit extends MockOctokit {
constructor(options) {
super(options);
this.rest = {
repos: {
getLatestRelease: jest.fn().mockResolvedValue({
data: {
tag_name: 'v2.10.2' // Use a version that we know works with our tests
}
})
}
};
}
};
}
}
};
3 changes: 3 additions & 0 deletions __tests__/__mocks__/@octokit/plugin-rest-endpoint-methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
restEndpointMethods: jest.fn()
};
11 changes: 11 additions & 0 deletions __tests__/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,20 @@ describe('install', () => {
expect(result).toContain(version)
})
it('can install latest version', async () => {
// Set GITHUB_TOKEN for this test
process.env.GITHUB_TOKEN = 'fake-token-for-testing'
const commandPath = await install('latest')
core.addPath(commandPath)
const result = await runCommand('docker-compose version')
expect(result).not.toBeFalsy()
// Clean up
delete process.env.GITHUB_TOKEN
})
it('throws error when GITHUB_TOKEN is missing for latest version', async () => {
// Ensure GITHUB_TOKEN is not set
delete process.env.GITHUB_TOKEN
await expect(install('latest')).rejects.toThrow(
'GITHUB_TOKEN environment variable is required to fetch the latest version'
)
})
})
Loading