mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-25 14:56:18 +08:00
Merge branch 'master' into releases/v1
This commit is contained in:
commit
e561eefa28
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,5 +1,10 @@
|
||||
__tests__/runner/*
|
||||
!lib/
|
||||
!node_modules
|
||||
|
||||
.idea
|
||||
*.iml
|
||||
__tests__/runner/*
|
||||
|
||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||
# Logs
|
||||
@ -42,7 +47,6 @@ bower_components
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
!node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
|
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at paul@nosphere.org. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
@ -2,10 +2,13 @@
|
||||
|
||||
This Github Action can be used to run arbitrary Gradle commands on any platform supported by Github Actions.
|
||||
|
||||
You might also be interested by the related [Gradle Plugin](https://github.com/eskatos/gradle-github-actions-plugin) that allows your build to easily get Github Actions environment and tag Gradle Build Scans accordingly.
|
||||
|
||||
## Usage
|
||||
|
||||
The following workflow will run `gradle build` using the wrapper from the repository on ubuntu, macos and windows:
|
||||
The following workflow will run `gradle build` using the wrapper from the repository on ubuntu, macos and windows. The only prerequisite is to have Java installed, you can define the version you need to run the build using the `actions/setup-java` action.
|
||||
|
||||
|
||||
|
||||
```yaml
|
||||
// .github/workflows/gradle-build-pr.yml
|
||||
@ -94,7 +97,7 @@ Moreover, you can use the following aliases:
|
||||
| `nightly` | The latest [nightly](https://gradle.org/nightly/), fails if none. |
|
||||
| `release-nightly` | The latest [release nightly](https://gradle.org/release-nightly/), fails if none. |
|
||||
|
||||
This can be handy to automatically test your build with the next Gradle version once a release candidate is out:
|
||||
This can be handy to, for example, automatically test your build with the next Gradle version once a release candidate is out:
|
||||
|
||||
```yaml
|
||||
// .github/workflows/test-gradle-rc.yml
|
||||
|
@ -4,10 +4,11 @@ import * as exec from "@actions/exec";
|
||||
export async function execute(executable: string, root: string, argv: string[]): Promise<BuildResult> {
|
||||
|
||||
let publishing = false;
|
||||
let buildScanLink: any = null;
|
||||
let buildScanUrl: string | undefined;
|
||||
|
||||
await exec.exec(executable, argv, {
|
||||
const status: number = await exec.exec(executable, argv, {
|
||||
cwd: root,
|
||||
ignoreReturnCode: true,
|
||||
listeners: {
|
||||
stdline: (line: string) => {
|
||||
if (line.startsWith("Publishing build scan...")) {
|
||||
@ -17,24 +18,25 @@ export async function execute(executable: string, root: string, argv: string[]):
|
||||
publishing = false
|
||||
}
|
||||
if (publishing && line.startsWith("http")) {
|
||||
buildScanLink = line.trim();
|
||||
buildScanUrl = line.trim();
|
||||
publishing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (buildScanLink != null) {
|
||||
return new BuildResultImpl(buildScanLink.toString());
|
||||
}
|
||||
return new BuildResultImpl(null as unknown as string);
|
||||
return new BuildResultImpl(status, buildScanUrl);
|
||||
}
|
||||
|
||||
export interface BuildResult {
|
||||
buildScanUrl: string
|
||||
readonly status: number
|
||||
readonly buildScanUrl?: string
|
||||
}
|
||||
|
||||
class BuildResultImpl implements BuildResult {
|
||||
constructor(readonly buildScanUrl: string) {
|
||||
constructor(
|
||||
readonly status: number,
|
||||
readonly buildScanUrl?: string
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
export function wrapperFilename() {
|
||||
const isWindows = process.platform === "win32";
|
||||
return isWindows ? "gradlew.bat" : "gradlew";
|
||||
const IS_WINDOWS = process.platform === "win32";
|
||||
|
||||
|
||||
export function wrapperFilename(): string {
|
||||
return IS_WINDOWS ? "gradlew.bat" : "gradlew";
|
||||
}
|
||||
|
||||
export function installScriptFilename() {
|
||||
const isWindows = process.platform === "win32";
|
||||
return isWindows ? "gradle.bat" : "gradle";
|
||||
|
||||
export function installScriptFilename(): string {
|
||||
return IS_WINDOWS ? "gradle.bat" : "gradle";
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import * as provision from "./provision";
|
||||
|
||||
|
||||
// Invoked by Github Actions
|
||||
async function run() {
|
||||
export async function run() {
|
||||
try {
|
||||
|
||||
const baseDirectory = process.env[`GITHUB_WORKSPACE`] || "";
|
||||
@ -19,10 +19,14 @@ async function run() {
|
||||
parseCommandLineArguments()
|
||||
);
|
||||
|
||||
if (result.buildScanUrl != null) {
|
||||
if (result.buildScanUrl) {
|
||||
core.setOutput("build-scan-url", result.buildScanUrl);
|
||||
}
|
||||
|
||||
if (result.status != 0) {
|
||||
core.setFailed(`Gradle process exited with status ${result.status}`)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
@ -9,8 +9,12 @@ import * as toolCache from "@actions/tool-cache";
|
||||
import * as gradlew from "./gradlew";
|
||||
|
||||
|
||||
const httpc = new httpm.HttpClient("eskatos/gradle-command-action");
|
||||
const gradleVersionsBaseUrl = "https://services.gradle.org/versions";
|
||||
|
||||
|
||||
/**
|
||||
* @return Gradle executable
|
||||
* @return Gradle executable path
|
||||
*/
|
||||
export async function gradleVersion(gradleVersion: string): Promise<string> {
|
||||
switch (gradleVersion) {
|
||||
@ -28,9 +32,6 @@ export async function gradleVersion(gradleVersion: string): Promise<string> {
|
||||
}
|
||||
|
||||
|
||||
const gradleVersionsBaseUrl = "https://services.gradle.org/versions";
|
||||
|
||||
|
||||
async function gradleCurrent(): Promise<string> {
|
||||
const json = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
|
||||
return provisionGradle(json.version, json.downloadUrl);
|
||||
@ -39,7 +40,7 @@ async function gradleCurrent(): Promise<string> {
|
||||
|
||||
async function gradleReleaseCandidate(): Promise<string> {
|
||||
const json = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`);
|
||||
if (json != null) {
|
||||
if (json) {
|
||||
return provisionGradle(json.version, json.downloadUrl);
|
||||
}
|
||||
return gradleCurrent();
|
||||
@ -60,39 +61,32 @@ async function gradleReleaseNightly(): Promise<string> {
|
||||
|
||||
async function gradle(version: string): Promise<string> {
|
||||
const declaration = await findGradleVersionDeclaration(version);
|
||||
if (declaration == null) {
|
||||
if (!declaration) {
|
||||
throw new Error(`Gradle version ${version} does not exists`);
|
||||
}
|
||||
return provisionGradle(declaration.version, declaration.downloadUrl);
|
||||
}
|
||||
|
||||
|
||||
async function gradleVersionDeclaration(url: string): Promise<any | null> {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const response = await httpc.get(url);
|
||||
const body = await response.readBody();
|
||||
const json = JSON.parse(body);
|
||||
return (json == null || json.version == null || json.version.length <= 0)
|
||||
? null
|
||||
: json
|
||||
async function gradleVersionDeclaration(url: string): Promise<any | undefined> {
|
||||
const json: any = await httpGetJson(url);
|
||||
return (json.version && json.version.length > 0) ? json : undefined
|
||||
}
|
||||
|
||||
|
||||
async function findGradleVersionDeclaration(version: string): Promise<any | null> {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const response = await httpc.get(`${gradleVersionsBaseUrl}/all`);
|
||||
const body = await response.readBody();
|
||||
const json = JSON.parse(body);
|
||||
const found = json.find(entry => {
|
||||
return entry.version == version;
|
||||
async function findGradleVersionDeclaration(version: string): Promise<any | undefined> {
|
||||
const json: any = await httpGetJson(`${gradleVersionsBaseUrl}/all`);
|
||||
const found: any = json.find((entry: any) => {
|
||||
return entry.version === version;
|
||||
});
|
||||
return found != undefined ? found : null
|
||||
return found ? found : undefined
|
||||
}
|
||||
|
||||
|
||||
async function provisionGradle(version: string, url: string): Promise<string> {
|
||||
|
||||
const cachedInstall: string = toolCache.find("gradle", version);
|
||||
if (cachedInstall != null && cachedInstall.length > 0) {
|
||||
if (cachedInstall.length > 0) {
|
||||
const cachedExecutable = executableFrom(cachedInstall);
|
||||
core.info(`Provisioned Gradle executable ${cachedExecutable}`);
|
||||
return cachedExecutable;
|
||||
@ -130,9 +124,15 @@ function executableFrom(installDir: string): string {
|
||||
}
|
||||
|
||||
|
||||
async function httpGetJson(url: string): Promise<any> {
|
||||
const response = await httpc.get(url);
|
||||
const body = await response.readBody();
|
||||
return JSON.parse(body);
|
||||
}
|
||||
|
||||
|
||||
async function httpDownload(url: string, path: string): Promise<void> {
|
||||
return new Promise<void>(function (resolve, reject) {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const writeStream = fs.createWriteStream(path);
|
||||
httpc.get(url).then(response => {
|
||||
response.message.pipe(writeStream)
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"incremental": true, /* Enable incremental compilation */
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
@ -15,7 +15,7 @@
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
"removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
@ -23,13 +23,13 @@
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"strictNullChecks": true, /* Enable strict null checks. */
|
||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user