Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
coturiv committed Nov 29, 2019
0 parents commit 688c4e6
Show file tree
Hide file tree
Showing 189 changed files with 20,126 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "CI"

on:
push: {branches: master}
pull_request: {branches: master}
repository_dispatch:

jobs:
job_1:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- run: npm ci
- run: npm run build
- run: npm test
- name: Use coturiv/setup-ionic
uses: ./
with:
cordova-version: 8
- name: Run cordova project tests
run: |
ionic info
ionic start testapp blank --cordova --type angular --no-link --no-git
cd testapp
ionic cordova platform add android@latest
ionic cordova build android
93 changes: 93 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
__tests__/runner/*

# comment out in distribution branches
!node_modules/

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
25 changes: 25 additions & 0 deletions .renovaterc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": [
"config:base",
"schedule:monthly",
":preserveSemverRanges",
":disableDevDependencies"
],
"automerge": true,
"rebaseStalePrs": true,
"separateMajorMinor": true,
"groupName": "all dependencies",
"groupSlug": "all",
"labels": [
"deps"
],
"packageRules": [
{
"packagePatterns": [
"*"
],
"groupName": "all dependencies",
"groupSlug": "all"
}
]
}
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## setup-ionic

[![](https://github.com/coturiv/setup-ionic/workflows/CI/badge.svg)](https://github.com/coturiv/setup-ionic/actions)

Set up your GitHub Actions workflow with Cordova/Ionic environment. Only supports macos & ubuntu at this time.

## example usage:

```
- name: Use coturiv/setup-ionic
uses: coturiv/[email protected]
with:
cordova-version: 8
- name: Build
run: |
ionic cordova build android --prod
```
12 changes: 12 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
// const ip = path.join(__dirname, '..', 'lib', 'main.js');
// const options: cp.ExecSyncOptions = {
// env: process.env
// };
// console.log(cp.execSync(`node ${ip}`, options).toString());
});
23 changes: 23 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Setup Ionic'
description: 'Set up your GitHub Actions workflow with Cordova/Ionic environment. Only supports macos & ubuntu at this time.'
author: 'coturiv'
branding:
color: purple
icon: code

inputs:
cordova-version:
description: Version range or exact version of Cordova to use
default: '8'
ionic-version:
description: Version range or exact version of Ionic to use
install-java:
description: Whether to install Java
default: true
install-pods:
description: Whether to install CocoaPods
default: true

runs:
using: 'node12'
main: 'lib/main.js'
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}
21 changes: 21 additions & 0 deletions lib/install-openjdk-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Install OpenJDK 8
sudo apt-get update
sudo apt-get install -y --no-install-recommends openjdk-8-jdk
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /var/cache/oracle-jdk8-installer
java -version

# Install Gradle
# GRADLE_VERSION=4.10.3
# wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-all.zip
# mkdir /opt/gradle
# unzip -d /opt/gradle gradle-${GRADLE_VERSION}-all.zip
# rm gradle-${GRADLE_VERSION}-all.zip
# ln -s /opt/gradle/gradle-${GRADLE_VERSION}/bin/gradle /usr/bin/gradle
# mkdir .gradle \

# gradle -v

122 changes: 122 additions & 0 deletions lib/installer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const child = __importStar(require("child_process"));
const path = __importStar(require("path"));
const tc = __importStar(require("@actions/tool-cache"));
const core = __importStar(require("@actions/core"));
/**
* Install Cordova Cli
*
* https://www.npmjs.com/package/cordova
*
* @param version
*/
function installCordova(version) {
return __awaiter(this, void 0, void 0, function* () {
yield installNpmPkg('cordova', version);
// install cordova-res
// https://github.com/ionic-team/cordova-res
// await installNpmPkg('cordova-res');
});
}
exports.installCordova = installCordova;
/**
* Install Ionic Cli
*
* https://www.npmjs.com/package/ionic
*/
function installIonic(version) {
return __awaiter(this, void 0, void 0, function* () {
yield installNpmPkg('ionic', version);
});
}
exports.installIonic = installIonic;
/**
* Install Java
*
*/
function installJava() {
return __awaiter(this, void 0, void 0, function* () {
if (process.platform === 'linux') {
yield exec2(path.join(__dirname, 'install-openjdk-8'));
}
});
}
exports.installJava = installJava;
/**
* Install CocoaPods
*
*/
function installPods() {
return __awaiter(this, void 0, void 0, function* () {
if (process.platform === 'darwin') {
yield exec2(`sudo gem install cocoapods`);
}
});
}
exports.installPods = installPods;
/**
* Install NPM Package
*
* @param pkg : name of package
* @param version : version
*/
function installNpmPkg(pkg, version) {
return __awaiter(this, void 0, void 0, function* () {
// attach cached package
if (version) {
const packageDir = tc.find(pkg, version);
if (packageDir) {
core.addPath(packageDir);
return;
}
}
// install npm package
yield exec2(`sudo npm install -g ${pkg}${version ? '@' + version : ''}`);
let installedPath = yield exec2(`echo $(npm root -g)/${pkg}`);
if (!installedPath) {
return;
}
// remove linebreak in the command
installedPath = installedPath.replace(/(\r\n|\n|\r)/gm, "");
if (!version) {
// installed version
version = (yield exec2(`node -p "require('${installedPath}/package.json').version"`));
// cache installed package
const cachedPath = yield tc.cacheDir(installedPath, pkg, version);
core.addPath(cachedPath);
}
});
}
exports.installNpmPkg = installNpmPkg;
function exec2(command) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
child.exec(command, (err, stdout, stderr) => {
if (stderr) {
resolve();
}
if (err) {
console.log(err);
reject(err);
}
resolve(stdout);
});
});
});
}
Loading

0 comments on commit 688c4e6

Please sign in to comment.