mirror of
https://github.com/actions/setup-go.git
synced 2025-06-13 09:07:13 +02:00
Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
268d8c0ca0 | |||
f279813975 | |||
1022489cb7 | |||
e0dce94eb0 | |||
dab57c7c68 | |||
f2e56d8191 | |||
edd0aca6b1 | |||
f3e3b7c2f2 | |||
4a0c081511 | |||
185e7f2f01 | |||
44a19cee0e | |||
bf3c3cc849 | |||
f9b96e0433 | |||
ff877a8139 | |||
978085939e | |||
481b13a4cc | |||
76faaf8531 | |||
14274b54cb | |||
95fd3774de | |||
985d5990dd | |||
0b05709db8 | |||
a7338d1fc9 | |||
c35e03b512 | |||
864dd77064 | |||
233e44dd5f | |||
afb42575fb | |||
049de84649 |
19
.github/workflows/versions.yml
vendored
19
.github/workflows/versions.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
go: [1.12, 1.13, 1.14]
|
||||
go: [1.17, 1.18, 1.19]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -107,3 +107,20 @@ jobs:
|
||||
- name: verify go
|
||||
run: __tests__/verify-go.sh ${{ matrix.go }}
|
||||
shell: bash
|
||||
|
||||
architecture:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
go-version: [1.16, 1.17]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Go and check latest
|
||||
uses: ./
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
architecture: x64
|
||||
- name: Verify Go
|
||||
run: go version
|
@ -13,6 +13,8 @@ let matchers = require('../matchers.json');
|
||||
let goTestManifest = require('./data/versions-manifest.json');
|
||||
let matcherPattern = matchers.problemMatcher[0].pattern[0];
|
||||
let matcherRegExp = new RegExp(matcherPattern.regexp);
|
||||
let win32Join = path.win32.join;
|
||||
let posixJoin = path.posix.join;
|
||||
|
||||
describe('setup-go', () => {
|
||||
let inputs = {} as any;
|
||||
@ -27,8 +29,10 @@ describe('setup-go', () => {
|
||||
let getSpy: jest.SpyInstance;
|
||||
let platSpy: jest.SpyInstance;
|
||||
let archSpy: jest.SpyInstance;
|
||||
let joinSpy: jest.SpyInstance;
|
||||
let dlSpy: jest.SpyInstance;
|
||||
let extractTarSpy: jest.SpyInstance;
|
||||
let extractZipSpy: jest.SpyInstance;
|
||||
let cacheSpy: jest.SpyInstance;
|
||||
let dbgSpy: jest.SpyInstance;
|
||||
let whichSpy: jest.SpyInstance;
|
||||
@ -61,10 +65,21 @@ describe('setup-go', () => {
|
||||
archSpy.mockImplementation(() => os['arch']);
|
||||
execSpy = jest.spyOn(cp, 'execSync');
|
||||
|
||||
// switch path join behaviour based on set os.platform
|
||||
joinSpy = jest.spyOn(path, 'join');
|
||||
joinSpy.mockImplementation((...paths: string[]): string => {
|
||||
if (os['platform'] == 'win32') {
|
||||
return win32Join(...paths);
|
||||
}
|
||||
|
||||
return posixJoin(...paths);
|
||||
});
|
||||
|
||||
// @actions/tool-cache
|
||||
findSpy = jest.spyOn(tc, 'find');
|
||||
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||
extractTarSpy = jest.spyOn(tc, 'extractTar');
|
||||
extractZipSpy = jest.spyOn(tc, 'extractZip');
|
||||
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||
getSpy = jest.spyOn(im, 'getVersionsDist');
|
||||
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||
@ -325,6 +340,31 @@ describe('setup-go', () => {
|
||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||
});
|
||||
|
||||
it('downloads a version not in the cache (windows)', async () => {
|
||||
os.platform = 'win32';
|
||||
os.arch = 'x64';
|
||||
|
||||
inputs['go-version'] = '1.13.1';
|
||||
process.env['RUNNER_TEMP'] = 'C:\\temp\\';
|
||||
|
||||
findSpy.mockImplementation(() => '');
|
||||
dlSpy.mockImplementation(() => 'C:\\temp\\some\\path');
|
||||
extractZipSpy.mockImplementation(() => 'C:\\temp\\some\\other\\path');
|
||||
|
||||
let toolPath = path.normalize('C:\\cache\\go\\1.13.0\\x64');
|
||||
cacheSpy.mockImplementation(() => toolPath);
|
||||
|
||||
await main.run();
|
||||
|
||||
let expPath = path.win32.join(toolPath, 'bin');
|
||||
expect(dlSpy).toHaveBeenCalledWith(
|
||||
'https://storage.googleapis.com/golang/go1.13.1.windows-amd64.zip',
|
||||
'C:\\temp\\go1.13.1.windows-amd64.zip',
|
||||
undefined
|
||||
);
|
||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||
});
|
||||
|
||||
it('does not find a version that does not exist', async () => {
|
||||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
@ -413,7 +453,7 @@ describe('setup-go', () => {
|
||||
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||
});
|
||||
|
||||
it('falls back to a version from node dist', async () => {
|
||||
it('falls back to a version from go dist', async () => {
|
||||
os.platform = 'linux';
|
||||
os.arch = 'x64';
|
||||
|
||||
@ -839,5 +879,40 @@ exclude example.com/thismodule v1.3.0
|
||||
`::error::The specified go version file at: go.mod does not exist${osm.EOL}`
|
||||
);
|
||||
});
|
||||
|
||||
it('acquires specified architecture of go', async () => {
|
||||
for (const {arch, version, osSpec} of [
|
||||
{arch: 'amd64', version: '1.13.7', osSpec: 'linux'},
|
||||
{arch: 'armv6l', version: '1.12.2', osSpec: 'linux'}
|
||||
]) {
|
||||
os.platform = osSpec;
|
||||
os.arch = arch;
|
||||
|
||||
const fileExtension = os.platform === 'win32' ? 'zip' : 'tar.gz';
|
||||
|
||||
const platform = os.platform === 'win32' ? 'win' : os.platform;
|
||||
|
||||
inputs['go-version'] = version;
|
||||
inputs['architecture'] = arch;
|
||||
|
||||
let expectedUrl =
|
||||
platform === 'win32'
|
||||
? `https://github.com/actions/go-versions/releases/download/${version}/go-${version}-${platform}-${arch}.${fileExtension}`
|
||||
: `https://storage.googleapis.com/golang/go${version}.${osSpec}-${arch}.${fileExtension}`;
|
||||
|
||||
// ... but not in the local cache
|
||||
findSpy.mockImplementation(() => '');
|
||||
|
||||
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||
let toolPath = path.normalize(`/cache/go/${version}/${arch}`);
|
||||
cacheSpy.mockImplementation(async () => toolPath);
|
||||
|
||||
await main.run();
|
||||
|
||||
expect(logSpy).toHaveBeenCalledWith(
|
||||
`Acquiring go${version} from ${expectedUrl}`
|
||||
);
|
||||
}
|
||||
}, 100000);
|
||||
});
|
||||
});
|
||||
|
@ -17,6 +17,8 @@ inputs:
|
||||
default: false
|
||||
cache-dependency-path:
|
||||
description: 'Used to specify the path to a dependency file - go.sum'
|
||||
architecture:
|
||||
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
|
||||
outputs:
|
||||
go-version:
|
||||
description: 'The installed Go version. Useful when given a version range as input.'
|
||||
|
56
dist/setup/index.js
vendored
56
dist/setup/index.js
vendored
@ -62858,13 +62858,12 @@ const httpm = __importStar(__nccwpck_require__(6255));
|
||||
const sys = __importStar(__nccwpck_require__(4300));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||
function getGo(versionSpec, checkLatest, auth) {
|
||||
function getGo(versionSpec, checkLatest, auth, arch = os_1.default.arch()) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let osPlat = os_1.default.platform();
|
||||
let osArch = os_1.default.arch();
|
||||
if (checkLatest) {
|
||||
core.info('Attempting to resolve the latest version from the manifest...');
|
||||
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth);
|
||||
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, true, auth, arch);
|
||||
if (resolvedVersion) {
|
||||
versionSpec = resolvedVersion;
|
||||
core.info(`Resolved as '${versionSpec}'`);
|
||||
@ -62875,7 +62874,7 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||
}
|
||||
// check cache
|
||||
let toolPath;
|
||||
toolPath = tc.find('go', versionSpec);
|
||||
toolPath = tc.find('go', versionSpec, arch);
|
||||
// If not found in cache, download
|
||||
if (toolPath) {
|
||||
core.info(`Found in cache @ ${toolPath}`);
|
||||
@ -62888,9 +62887,9 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||
// Try download from internal distribution (popular versions only)
|
||||
//
|
||||
try {
|
||||
info = yield getInfoFromManifest(versionSpec, true, auth);
|
||||
info = yield getInfoFromManifest(versionSpec, true, auth, arch);
|
||||
if (info) {
|
||||
downloadPath = yield installGoVersion(info, auth);
|
||||
downloadPath = yield installGoVersion(info, auth, arch);
|
||||
}
|
||||
else {
|
||||
core.info('Not found in manifest. Falling back to download directly from Go');
|
||||
@ -62911,13 +62910,13 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||
// Download from storage.googleapis.com
|
||||
//
|
||||
if (!downloadPath) {
|
||||
info = yield getInfoFromDist(versionSpec);
|
||||
info = yield getInfoFromDist(versionSpec, arch);
|
||||
if (!info) {
|
||||
throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
|
||||
throw new Error(`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`);
|
||||
}
|
||||
try {
|
||||
core.info('Install from dist');
|
||||
downloadPath = yield installGoVersion(info, undefined);
|
||||
downloadPath = yield installGoVersion(info, undefined, arch);
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(`Failed to download version ${versionSpec}: ${err}`);
|
||||
@ -62927,10 +62926,10 @@ function getGo(versionSpec, checkLatest, auth) {
|
||||
});
|
||||
}
|
||||
exports.getGo = getGo;
|
||||
function resolveVersionFromManifest(versionSpec, stable, auth) {
|
||||
function resolveVersionFromManifest(versionSpec, stable, auth, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const info = yield getInfoFromManifest(versionSpec, stable, auth);
|
||||
const info = yield getInfoFromManifest(versionSpec, stable, auth, arch);
|
||||
return info === null || info === void 0 ? void 0 : info.resolvedVersion;
|
||||
}
|
||||
catch (err) {
|
||||
@ -62939,10 +62938,14 @@ function resolveVersionFromManifest(versionSpec, stable, auth) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function installGoVersion(info, auth) {
|
||||
function installGoVersion(info, auth, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||
const downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
|
||||
// Windows requires that we keep the extension (.zip) for extraction
|
||||
const isWindows = os_1.default.platform() === 'win32';
|
||||
const tempDir = process.env.RUNNER_TEMP || '.';
|
||||
const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined;
|
||||
const downloadPath = yield tc.downloadTool(info.downloadUrl, fileName, auth);
|
||||
core.info('Extracting Go...');
|
||||
let extPath = yield extractGoArchive(downloadPath);
|
||||
core.info(`Successfully extracted go to ${extPath}`);
|
||||
@ -62950,7 +62953,7 @@ function installGoVersion(info, auth) {
|
||||
extPath = path.join(extPath, 'go');
|
||||
}
|
||||
core.info('Adding to the cache ...');
|
||||
const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion));
|
||||
const cachedDir = yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion), arch);
|
||||
core.info(`Successfully cached go to ${cachedDir}`);
|
||||
return cachedDir;
|
||||
});
|
||||
@ -62969,12 +62972,12 @@ function extractGoArchive(archivePath) {
|
||||
});
|
||||
}
|
||||
exports.extractGoArchive = extractGoArchive;
|
||||
function getInfoFromManifest(versionSpec, stable, auth) {
|
||||
function getInfoFromManifest(versionSpec, stable, auth, arch = os_1.default.arch()) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let info = null;
|
||||
const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth, 'main');
|
||||
core.info(`matching ${versionSpec}...`);
|
||||
const rel = yield tc.findFromManifest(versionSpec, stable, releases);
|
||||
const rel = yield tc.findFromManifest(versionSpec, stable, releases, arch);
|
||||
if (rel && rel.files.length > 0) {
|
||||
info = {};
|
||||
info.type = 'manifest';
|
||||
@ -62986,10 +62989,10 @@ function getInfoFromManifest(versionSpec, stable, auth) {
|
||||
});
|
||||
}
|
||||
exports.getInfoFromManifest = getInfoFromManifest;
|
||||
function getInfoFromDist(versionSpec) {
|
||||
function getInfoFromDist(versionSpec, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let version;
|
||||
version = yield findMatch(versionSpec);
|
||||
version = yield findMatch(versionSpec, arch);
|
||||
if (!version) {
|
||||
return null;
|
||||
}
|
||||
@ -63002,9 +63005,9 @@ function getInfoFromDist(versionSpec) {
|
||||
};
|
||||
});
|
||||
}
|
||||
function findMatch(versionSpec) {
|
||||
function findMatch(versionSpec, arch = os_1.default.arch()) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let archFilter = sys.getArch();
|
||||
let archFilter = sys.getArch(arch);
|
||||
let platFilter = sys.getPlatform();
|
||||
let result;
|
||||
let match;
|
||||
@ -63135,6 +63138,7 @@ const cache_restore_1 = __nccwpck_require__(9517);
|
||||
const cache_utils_1 = __nccwpck_require__(1678);
|
||||
const child_process_1 = __importDefault(__nccwpck_require__(2081));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
@ -63145,11 +63149,15 @@ function run() {
|
||||
const versionSpec = resolveVersionInput();
|
||||
const cache = core.getBooleanInput('cache');
|
||||
core.info(`Setup go version spec ${versionSpec}`);
|
||||
let arch = core.getInput('architecture');
|
||||
if (!arch) {
|
||||
arch = os_1.default.arch();
|
||||
}
|
||||
if (versionSpec) {
|
||||
let token = core.getInput('token');
|
||||
let auth = !token || cache_utils_1.isGhes() ? undefined : `token ${token}`;
|
||||
const checkLatest = core.getBooleanInput('check-latest');
|
||||
const installDir = yield installer.getGo(versionSpec, checkLatest, auth);
|
||||
const installDir = yield installer.getGo(versionSpec, checkLatest, auth, arch);
|
||||
core.addPath(path_1.default.join(installDir, 'bin'));
|
||||
core.info('Added go to the path');
|
||||
const version = installer.makeSemver(versionSpec);
|
||||
@ -63282,9 +63290,8 @@ function getPlatform() {
|
||||
return plat;
|
||||
}
|
||||
exports.getPlatform = getPlatform;
|
||||
function getArch() {
|
||||
function getArch(arch) {
|
||||
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
|
||||
let arch = os.arch();
|
||||
// wants amd64, 386, arm64, armv61, ppc641e, s390x
|
||||
// currently not supported by runner but future proofed mapping
|
||||
switch (arch) {
|
||||
@ -63297,6 +63304,9 @@ function getArch() {
|
||||
case 'x32':
|
||||
arch = '386';
|
||||
break;
|
||||
case 'arm':
|
||||
arch = 'armv6l';
|
||||
break;
|
||||
}
|
||||
return arch;
|
||||
}
|
||||
|
@ -1,17 +1,115 @@
|
||||
# Contributors
|
||||
|
||||
Thank you for contributing!
|
||||
|
||||
# Checkin
|
||||
We have prepared a short guide so that the process of making your contribution is as simple and clear as possible. Please check it out before you contribute!
|
||||
|
||||
- Do checkin source (src)
|
||||
- Do checkin build output (lib)
|
||||
- Do checkin runtime node_modules
|
||||
- Do not checkin
|
||||
## How can I contribute...
|
||||
|
||||
# Adding a dev dependency
|
||||
* [Contribute Documentation:green_book:](#contribute-documentation)
|
||||
|
||||
Remember to update .gitignore.
|
||||
* [Contribute Code :computer:](#contribute-code)
|
||||
|
||||
# Updating toolkit dependency
|
||||
* [Provide Support on Issues:pencil:](#provide-support-on-issues)
|
||||
|
||||
Until released publically, update tgz packages in toolkit
|
||||
* [Review Pull Requests:mag:](#review-pull-requests)
|
||||
|
||||
## Contribute documentation
|
||||
|
||||
Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies and how we tell others everything they need to be able to use this project or contribute to it.
|
||||
|
||||
Documentation contributions of any size are welcome! Feel free to contribute even if you're just rewording a sentence to be more clear, or fixing a spelling mistake!
|
||||
|
||||
**How to contribute:**
|
||||
|
||||
Pull requests are the easiest way to contribute changes to git repos at GitHub. They are the preferred contribution method, as they offer a nice way of commenting and amending the proposed changes.
|
||||
|
||||
- Please check that no one else has already created a pull request with these changes
|
||||
- Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request
|
||||
- Make sure your changes are formatted correctly and consistently with the rest of the documentation
|
||||
- Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything
|
||||
- If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section
|
||||
- If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated
|
||||
|
||||
**Once you've filed the pull request:**
|
||||
|
||||
- Maintainers will review your pull request
|
||||
- If a maintainer requests changes, first of all, try to think about this request critically and only after that implement and request another review
|
||||
- If your PR gets accepted, it will soon be merged into the main branch. But your contribution will take effect only after the release of a new version of the action
|
||||
> Sometimes maintainers reject pull requests and that's ok! Usually, along with rejection, we supply the reason for it. Nonetheless, we still really appreciate you taking the time to do it, and we don't take that lightly :heart:
|
||||
|
||||
## Contribute code
|
||||
|
||||
We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others.
|
||||
|
||||
Code contributions of just about any size are acceptable!
|
||||
|
||||
The main difference between code contributions and documentation contributions is that contributing code requires the inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added unless the maintainers consider the specific tests to be either impossible or way too much of a burden for such a contribution.
|
||||
|
||||
**How to contribute:**
|
||||
|
||||
Pull requests are the easiest way to contribute changes to git repos at GitHub. They are the preferred contribution method, as they offer a nice way of commenting and amending the proposed changes.
|
||||
|
||||
- Please check that no one else has already created a pull request with these changes
|
||||
- Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request
|
||||
- **Run `pre-checkin` script to format, build and test changes**
|
||||
- Make sure your changes are well formatted and that all tests are passing
|
||||
- If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section
|
||||
- If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated
|
||||
|
||||
**Learn more about how to work with the repository:**
|
||||
|
||||
- To implement new features or fix bugs, you need to make changes to the `.ts` files, which are located in the `src` folder
|
||||
- To comply with the code style, **you need to run the `format` script**
|
||||
- To transpile source code to `javascript` we use [NCC](https://github.com/vercel/ncc). **It is very important to run the `build` script after making changes**, otherwise your changes will not get into the final `javascript` build
|
||||
- You can also start formatting, building code, and testing with a single `pre-checkin` command
|
||||
|
||||
**Learn more about how to implement tests:**
|
||||
|
||||
Adding or changing tests is an integral part of making a change to the code.
|
||||
Unit tests are in the `__tests__` folder, and end-to-end tests are in the `workflows` folder (in particular, in the file [versions.yml](https://github.com/actions/setup-go/blob/main/.github/workflows/versions.yml)).
|
||||
|
||||
- The contributor can add various types of tests (like unit tests or end-to-end tests), which, in his opinion, will be necessary and sufficient for testing new or changed functionality
|
||||
- Tests should cover a successful execution, as well as some edge cases and possible errors
|
||||
- As already mentioned, pull requests without tests will be considered more carefully by maintainers. If you are sure that in this situation the tests are not needed or cannot be implemented with a commensurate effort - please add this clarification message to your pull request
|
||||
|
||||
**Once you've filed the pull request:**
|
||||
|
||||
- CI will start automatically with some checks. Wait until the end of the execution and make sure that all checks passed successfully. If some checks fail, you can open them one by one, try to find the reason for failing and make changes to your code to resolve the problem
|
||||
- Maintainers will review your pull request
|
||||
- If a maintainer requests changes, first of all, try to think about his request critically and only after that implement and request another review
|
||||
- If your PR gets accepted, it will soon be merged into the main branch. But your contribution will take effect only after the release of a new version of the action
|
||||
> Sometimes maintainers reject pull requests and that's ok! Usually, along with rejection, we supply the reason for it. Nonetheless, we still really appreciate you taking the time to do it, and we don't take that lightly :heart:
|
||||
|
||||
## Provide support on issues
|
||||
|
||||
Helping out other users with their questions is an awesome way of contributing to any community. It's not uncommon for most of the issues on open source projects to be support-related questions by users trying to understand something they ran into or find their way around a known bug.
|
||||
|
||||
**To help other folks out with their questions:**
|
||||
|
||||
- Go to the [issue tracker](https://github.com/actions/setup-go/issues)
|
||||
- Read through the list until you find something that you're familiar enough with to answer to
|
||||
- Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on
|
||||
- Once the discussion wraps up and things are clarified, ask the original issue filer (or a maintainer) to close it for you
|
||||
|
||||
*Some notes on picking up support issues:*
|
||||
|
||||
- Avoid responding to issues you don't know you can answer accurately
|
||||
- Try to refer to past issues with accepted answers as much as possible. Link to them from your replies
|
||||
- Be kind and patient with users. Often, folks who have run into confusing things might be upset or impatient. This is natural. If you feel uncomfortable in conversation with them, it's better to stay away or withdraw from the issue.
|
||||
|
||||
> If some user is violating our code of conduct [standards](https://github.com/actions/setup-go/blob/main/CODE_OF_CONDUCT.md#our-standards), refer to the [Enforcement](https://github.com/actions/setup-go/blob/main/CODE_OF_CONDUCT.md#enforcement) section of the Code of Conduct to resolve the conflict
|
||||
|
||||
|
||||
## Review pull requests
|
||||
|
||||
|
||||
Another great way to contribute is pull request reviews. Please, be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) Please, always respond with respect, and be understanding, but don't feel like you need to sacrifice your standards for their sake, either.
|
||||
|
||||
**How to review:**
|
||||
|
||||
- Go to the [pull requests](https://github.com/actions/setup-go/pulls)
|
||||
- Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.)
|
||||
- Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.
|
||||
> Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not
|
||||
- Submit your review, which may include comments, an approval, or a changes request
|
@ -32,17 +32,18 @@ export interface IGoVersionInfo {
|
||||
export async function getGo(
|
||||
versionSpec: string,
|
||||
checkLatest: boolean,
|
||||
auth: string | undefined
|
||||
auth: string | undefined,
|
||||
arch = os.arch()
|
||||
) {
|
||||
let osPlat: string = os.platform();
|
||||
let osArch: string = os.arch();
|
||||
|
||||
if (checkLatest) {
|
||||
core.info('Attempting to resolve the latest version from the manifest...');
|
||||
const resolvedVersion = await resolveVersionFromManifest(
|
||||
versionSpec,
|
||||
true,
|
||||
auth
|
||||
auth,
|
||||
arch
|
||||
);
|
||||
if (resolvedVersion) {
|
||||
versionSpec = resolvedVersion;
|
||||
@ -54,7 +55,7 @@ export async function getGo(
|
||||
|
||||
// check cache
|
||||
let toolPath: string;
|
||||
toolPath = tc.find('go', versionSpec);
|
||||
toolPath = tc.find('go', versionSpec, arch);
|
||||
// If not found in cache, download
|
||||
if (toolPath) {
|
||||
core.info(`Found in cache @ ${toolPath}`);
|
||||
@ -68,9 +69,9 @@ export async function getGo(
|
||||
// Try download from internal distribution (popular versions only)
|
||||
//
|
||||
try {
|
||||
info = await getInfoFromManifest(versionSpec, true, auth);
|
||||
info = await getInfoFromManifest(versionSpec, true, auth, arch);
|
||||
if (info) {
|
||||
downloadPath = await installGoVersion(info, auth);
|
||||
downloadPath = await installGoVersion(info, auth, arch);
|
||||
} else {
|
||||
core.info(
|
||||
'Not found in manifest. Falling back to download directly from Go'
|
||||
@ -95,16 +96,16 @@ export async function getGo(
|
||||
// Download from storage.googleapis.com
|
||||
//
|
||||
if (!downloadPath) {
|
||||
info = await getInfoFromDist(versionSpec);
|
||||
info = await getInfoFromDist(versionSpec, arch);
|
||||
if (!info) {
|
||||
throw new Error(
|
||||
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`
|
||||
`Unable to find Go version '${versionSpec}' for platform ${osPlat} and architecture ${arch}.`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
core.info('Install from dist');
|
||||
downloadPath = await installGoVersion(info, undefined);
|
||||
downloadPath = await installGoVersion(info, undefined, arch);
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to download version ${versionSpec}: ${err}`);
|
||||
}
|
||||
@ -116,10 +117,11 @@ export async function getGo(
|
||||
async function resolveVersionFromManifest(
|
||||
versionSpec: string,
|
||||
stable: boolean,
|
||||
auth: string | undefined
|
||||
auth: string | undefined,
|
||||
arch: string
|
||||
): Promise<string | undefined> {
|
||||
try {
|
||||
const info = await getInfoFromManifest(versionSpec, stable, auth);
|
||||
const info = await getInfoFromManifest(versionSpec, stable, auth, arch);
|
||||
return info?.resolvedVersion;
|
||||
} catch (err) {
|
||||
core.info('Unable to resolve a version from the manifest...');
|
||||
@ -129,10 +131,17 @@ async function resolveVersionFromManifest(
|
||||
|
||||
async function installGoVersion(
|
||||
info: IGoVersionInfo,
|
||||
auth: string | undefined
|
||||
auth: string | undefined,
|
||||
arch: string
|
||||
): Promise<string> {
|
||||
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
|
||||
const downloadPath = await tc.downloadTool(info.downloadUrl, undefined, auth);
|
||||
|
||||
// Windows requires that we keep the extension (.zip) for extraction
|
||||
const isWindows = os.platform() === 'win32';
|
||||
const tempDir = process.env.RUNNER_TEMP || '.';
|
||||
const fileName = isWindows ? path.join(tempDir, info.fileName) : undefined;
|
||||
|
||||
const downloadPath = await tc.downloadTool(info.downloadUrl, fileName, auth);
|
||||
|
||||
core.info('Extracting Go...');
|
||||
let extPath = await extractGoArchive(downloadPath);
|
||||
@ -145,7 +154,8 @@ async function installGoVersion(
|
||||
const cachedDir = await tc.cacheDir(
|
||||
extPath,
|
||||
'go',
|
||||
makeSemver(info.resolvedVersion)
|
||||
makeSemver(info.resolvedVersion),
|
||||
arch
|
||||
);
|
||||
core.info(`Successfully cached go to ${cachedDir}`);
|
||||
return cachedDir;
|
||||
@ -167,7 +177,8 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
|
||||
export async function getInfoFromManifest(
|
||||
versionSpec: string,
|
||||
stable: boolean,
|
||||
auth: string | undefined
|
||||
auth: string | undefined,
|
||||
arch = os.arch()
|
||||
): Promise<IGoVersionInfo | null> {
|
||||
let info: IGoVersionInfo | null = null;
|
||||
const releases = await tc.getManifestFromRepo(
|
||||
@ -177,7 +188,7 @@ export async function getInfoFromManifest(
|
||||
'main'
|
||||
);
|
||||
core.info(`matching ${versionSpec}...`);
|
||||
const rel = await tc.findFromManifest(versionSpec, stable, releases);
|
||||
const rel = await tc.findFromManifest(versionSpec, stable, releases, arch);
|
||||
|
||||
if (rel && rel.files.length > 0) {
|
||||
info = <IGoVersionInfo>{};
|
||||
@ -191,10 +202,11 @@ export async function getInfoFromManifest(
|
||||
}
|
||||
|
||||
async function getInfoFromDist(
|
||||
versionSpec: string
|
||||
versionSpec: string,
|
||||
arch: string
|
||||
): Promise<IGoVersionInfo | null> {
|
||||
let version: IGoVersion | undefined;
|
||||
version = await findMatch(versionSpec);
|
||||
version = await findMatch(versionSpec, arch);
|
||||
if (!version) {
|
||||
return null;
|
||||
}
|
||||
@ -210,9 +222,10 @@ async function getInfoFromDist(
|
||||
}
|
||||
|
||||
export async function findMatch(
|
||||
versionSpec: string
|
||||
versionSpec: string,
|
||||
arch = os.arch()
|
||||
): Promise<IGoVersion | undefined> {
|
||||
let archFilter = sys.getArch();
|
||||
let archFilter = sys.getArch(arch);
|
||||
let platFilter = sys.getPlatform();
|
||||
|
||||
let result: IGoVersion | undefined;
|
||||
|
14
src/main.ts
14
src/main.ts
@ -7,6 +7,7 @@ import {restoreCache} from './cache-restore';
|
||||
import {isGhes, isCacheFeatureAvailable} from './cache-utils';
|
||||
import cp from 'child_process';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
@ -19,12 +20,23 @@ export async function run() {
|
||||
const cache = core.getBooleanInput('cache');
|
||||
core.info(`Setup go version spec ${versionSpec}`);
|
||||
|
||||
let arch = core.getInput('architecture');
|
||||
|
||||
if (!arch) {
|
||||
arch = os.arch();
|
||||
}
|
||||
|
||||
if (versionSpec) {
|
||||
let token = core.getInput('token');
|
||||
let auth = !token || isGhes() ? undefined : `token ${token}`;
|
||||
|
||||
const checkLatest = core.getBooleanInput('check-latest');
|
||||
const installDir = await installer.getGo(versionSpec, checkLatest, auth);
|
||||
const installDir = await installer.getGo(
|
||||
versionSpec,
|
||||
checkLatest,
|
||||
auth,
|
||||
arch
|
||||
);
|
||||
|
||||
core.addPath(path.join(installDir, 'bin'));
|
||||
core.info('Added go to the path');
|
||||
|
@ -15,9 +15,8 @@ export function getPlatform(): string {
|
||||
return plat;
|
||||
}
|
||||
|
||||
export function getArch(): string {
|
||||
export function getArch(arch: string): string {
|
||||
// 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
|
||||
let arch: string = os.arch();
|
||||
|
||||
// wants amd64, 386, arm64, armv61, ppc641e, s390x
|
||||
// currently not supported by runner but future proofed mapping
|
||||
@ -31,6 +30,9 @@ export function getArch(): string {
|
||||
case 'x32':
|
||||
arch = '386';
|
||||
break;
|
||||
case 'arm':
|
||||
arch = 'armv6l';
|
||||
break;
|
||||
}
|
||||
|
||||
return arch;
|
||||
|
Reference in New Issue
Block a user