Skip to content

Commit 688c4e6

Browse files
committed
Initial release
0 parents  commit 688c4e6

189 files changed

Lines changed: 20126 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "CI"
2+
3+
on:
4+
push: {branches: master}
5+
pull_request: {branches: master}
6+
repository_dispatch:
7+
8+
jobs:
9+
job_1:
10+
name: test
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
15+
- run: npm ci
16+
- run: npm run build
17+
- run: npm test
18+
- name: Use coturiv/setup-ionic
19+
uses: ./
20+
with:
21+
cordova-version: 8
22+
- name: Run cordova project tests
23+
run: |
24+
ionic info
25+
ionic start testapp blank --cordova --type angular --no-link --no-git
26+
cd testapp
27+
ionic cordova platform add android@latest
28+
ionic cordova build android

.gitignore

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
__tests__/runner/*
2+
3+
# comment out in distribution branches
4+
!node_modules/
5+
6+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
7+
# Logs
8+
logs
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
15+
# Diagnostic reports (https://nodejs.org/api/report.html)
16+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
17+
18+
# Runtime data
19+
pids
20+
*.pid
21+
*.seed
22+
*.pid.lock
23+
24+
# Directory for instrumented libs generated by jscoverage/JSCover
25+
lib-cov
26+
27+
# Coverage directory used by tools like istanbul
28+
coverage
29+
*.lcov
30+
31+
# nyc test coverage
32+
.nyc_output
33+
34+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
35+
.grunt
36+
37+
# Bower dependency directory (https://bower.io/)
38+
bower_components
39+
40+
# node-waf configuration
41+
.lock-wscript
42+
43+
# Compiled binary addons (https://nodejs.org/api/addons.html)
44+
build/Release
45+
46+
# Dependency directories
47+
jspm_packages/
48+
49+
# TypeScript v1 declaration files
50+
typings/
51+
52+
# TypeScript cache
53+
*.tsbuildinfo
54+
55+
# Optional npm cache directory
56+
.npm
57+
58+
# Optional eslint cache
59+
.eslintcache
60+
61+
# Optional REPL history
62+
.node_repl_history
63+
64+
# Output of 'npm pack'
65+
*.tgz
66+
67+
# Yarn Integrity file
68+
.yarn-integrity
69+
70+
# dotenv environment variables file
71+
.env
72+
.env.test
73+
74+
# parcel-bundler cache (https://parceljs.org/)
75+
.cache
76+
77+
# next.js build output
78+
.next
79+
80+
# nuxt.js build output
81+
.nuxt
82+
83+
# vuepress build output
84+
.vuepress/dist
85+
86+
# Serverless directories
87+
.serverless/
88+
89+
# FuseBox cache
90+
.fusebox/
91+
92+
# DynamoDB Local files
93+
.dynamodb/

.renovaterc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": [
3+
"config:base",
4+
"schedule:monthly",
5+
":preserveSemverRanges",
6+
":disableDevDependencies"
7+
],
8+
"automerge": true,
9+
"rebaseStalePrs": true,
10+
"separateMajorMinor": true,
11+
"groupName": "all dependencies",
12+
"groupSlug": "all",
13+
"labels": [
14+
"deps"
15+
],
16+
"packageRules": [
17+
{
18+
"packagePatterns": [
19+
"*"
20+
],
21+
"groupName": "all dependencies",
22+
"groupSlug": "all"
23+
}
24+
]
25+
}

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## setup-ionic
2+
3+
[![](https://github.com/coturiv/setup-ionic/workflows/CI/badge.svg)](https://github.com/coturiv/setup-ionic/actions)
4+
5+
Set up your GitHub Actions workflow with Cordova/Ionic environment. Only supports macos & ubuntu at this time.
6+
7+
## example usage:
8+
9+
```
10+
- name: Use coturiv/setup-ionic
11+
uses: coturiv/setup-ionic@v1.0.0
12+
with:
13+
cordova-version: 8
14+
15+
- name: Build
16+
run: |
17+
ionic cordova build android --prod
18+
19+
```

__tests__/main.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as process from 'process'
2+
import * as cp from 'child_process'
3+
import * as path from 'path'
4+
5+
// shows how the runner will run a javascript action with env / stdout protocol
6+
test('test runs', () => {
7+
// const ip = path.join(__dirname, '..', 'lib', 'main.js');
8+
// const options: cp.ExecSyncOptions = {
9+
// env: process.env
10+
// };
11+
// console.log(cp.execSync(`node ${ip}`, options).toString());
12+
});

action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Setup Ionic'
2+
description: 'Set up your GitHub Actions workflow with Cordova/Ionic environment. Only supports macos & ubuntu at this time.'
3+
author: 'coturiv'
4+
branding:
5+
color: purple
6+
icon: code
7+
8+
inputs:
9+
cordova-version:
10+
description: Version range or exact version of Cordova to use
11+
default: '8'
12+
ionic-version:
13+
description: Version range or exact version of Ionic to use
14+
install-java:
15+
description: Whether to install Java
16+
default: true
17+
install-pods:
18+
description: Whether to install CocoaPods
19+
default: true
20+
21+
runs:
22+
using: 'node12'
23+
main: 'lib/main.js'

jest.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
clearMocks: true,
3+
moduleFileExtensions: ['js', 'ts'],
4+
testEnvironment: 'node',
5+
testMatch: ['**/*.test.ts'],
6+
testRunner: 'jest-circus/runner',
7+
transform: {
8+
'^.+\\.ts$': 'ts-jest'
9+
},
10+
verbose: true
11+
}

lib/install-openjdk-8

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Install OpenJDK 8
4+
sudo apt-get update
5+
sudo apt-get install -y --no-install-recommends openjdk-8-jdk
6+
sudo apt-get clean
7+
sudo rm -rf /var/lib/apt/lists/*
8+
sudo rm -rf /var/cache/oracle-jdk8-installer
9+
java -version
10+
11+
# Install Gradle
12+
# GRADLE_VERSION=4.10.3
13+
# wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
14+
# mkdir /opt/gradle
15+
# unzip -d /opt/gradle gradle-${GRADLE_VERSION}-all.zip
16+
# rm gradle-${GRADLE_VERSION}-all.zip
17+
# ln -s /opt/gradle/gradle-${GRADLE_VERSION}/bin/gradle /usr/bin/gradle
18+
# mkdir .gradle \
19+
20+
# gradle -v
21+

lib/installer.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
return new (P || (P = Promise))(function (resolve, reject) {
4+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7+
step((generator = generator.apply(thisArg, _arguments || [])).next());
8+
});
9+
};
10+
var __importStar = (this && this.__importStar) || function (mod) {
11+
if (mod && mod.__esModule) return mod;
12+
var result = {};
13+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
14+
result["default"] = mod;
15+
return result;
16+
};
17+
Object.defineProperty(exports, "__esModule", { value: true });
18+
const child = __importStar(require("child_process"));
19+
const path = __importStar(require("path"));
20+
const tc = __importStar(require("@actions/tool-cache"));
21+
const core = __importStar(require("@actions/core"));
22+
/**
23+
* Install Cordova Cli
24+
*
25+
* https://www.npmjs.com/package/cordova
26+
*
27+
* @param version
28+
*/
29+
function installCordova(version) {
30+
return __awaiter(this, void 0, void 0, function* () {
31+
yield installNpmPkg('cordova', version);
32+
// install cordova-res
33+
// https://github.com/ionic-team/cordova-res
34+
// await installNpmPkg('cordova-res');
35+
});
36+
}
37+
exports.installCordova = installCordova;
38+
/**
39+
* Install Ionic Cli
40+
*
41+
* https://www.npmjs.com/package/ionic
42+
*/
43+
function installIonic(version) {
44+
return __awaiter(this, void 0, void 0, function* () {
45+
yield installNpmPkg('ionic', version);
46+
});
47+
}
48+
exports.installIonic = installIonic;
49+
/**
50+
* Install Java
51+
*
52+
*/
53+
function installJava() {
54+
return __awaiter(this, void 0, void 0, function* () {
55+
if (process.platform === 'linux') {
56+
yield exec2(path.join(__dirname, 'install-openjdk-8'));
57+
}
58+
});
59+
}
60+
exports.installJava = installJava;
61+
/**
62+
* Install CocoaPods
63+
*
64+
*/
65+
function installPods() {
66+
return __awaiter(this, void 0, void 0, function* () {
67+
if (process.platform === 'darwin') {
68+
yield exec2(`sudo gem install cocoapods`);
69+
}
70+
});
71+
}
72+
exports.installPods = installPods;
73+
/**
74+
* Install NPM Package
75+
*
76+
* @param pkg : name of package
77+
* @param version : version
78+
*/
79+
function installNpmPkg(pkg, version) {
80+
return __awaiter(this, void 0, void 0, function* () {
81+
// attach cached package
82+
if (version) {
83+
const packageDir = tc.find(pkg, version);
84+
if (packageDir) {
85+
core.addPath(packageDir);
86+
return;
87+
}
88+
}
89+
// install npm package
90+
yield exec2(`sudo npm install -g ${pkg}${version ? '@' + version : ''}`);
91+
let installedPath = yield exec2(`echo $(npm root -g)/${pkg}`);
92+
if (!installedPath) {
93+
return;
94+
}
95+
// remove linebreak in the command
96+
installedPath = installedPath.replace(/(\r\n|\n|\r)/gm, "");
97+
if (!version) {
98+
// installed version
99+
version = (yield exec2(`node -p "require('${installedPath}/package.json').version"`));
100+
// cache installed package
101+
const cachedPath = yield tc.cacheDir(installedPath, pkg, version);
102+
core.addPath(cachedPath);
103+
}
104+
});
105+
}
106+
exports.installNpmPkg = installNpmPkg;
107+
function exec2(command) {
108+
return __awaiter(this, void 0, void 0, function* () {
109+
return new Promise((resolve, reject) => {
110+
child.exec(command, (err, stdout, stderr) => {
111+
if (stderr) {
112+
resolve();
113+
}
114+
if (err) {
115+
console.log(err);
116+
reject(err);
117+
}
118+
resolve(stdout);
119+
});
120+
});
121+
});
122+
}

0 commit comments

Comments
 (0)