Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

feat!: /api/build endpoint, github action #15

Merged
merged 6 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
.vscode
node_modules
!action/node_modules
StuartRucker marked this conversation as resolved.
Show resolved Hide resolved
coverage
testing_logs/*
.firebase
20 changes: 20 additions & 0 deletions packages/action/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Post TAP Files'
StuartRucker marked this conversation as resolved.
Show resolved Hide resolved
description: 'Greet someone and record the time'
inputs:
github:
description: 'The Github Context JSON object'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think most of this information we need is populated in environment variables, see:

https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables

So, the user shouldn't need to provide this information.

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 environment variables are used, but I think they have to be used in the .github/workflows file, and this action.yaml metadata file just passes these environment variables into the javascript

required: true
default: 'None'
matrix:
description: 'Matrix information on run'
required: false
default: 'None'
os:
description: 'Operating System it is being run on'
required: true
logtype:
description: 'Type of Log.. e.g. (TAP, XML, ... TODO)'

runs:
using: 'node12'
main: 'index.js'
47 changes: 47 additions & 0 deletions packages/action/index-deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

var Parser = require('tap-parser');
const fetch = require('node-fetch');
const fs = require('fs');
const core = require('@actions/core');
const path = require("path");

try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('github-actor');

var metaData = {
github: JSON.parse(core.getInput('github')),
os: JSON.parse(core.getInput('os')),
matrix: JSON.parse(core.getInput('matrix'))
};


var data = [];
var p = new Parser();
p.on('result', function(assert){
data.push(assert);
});
p.on('complete',function(results){
var sendMe = JSON.stringify({summary: results, data: data, metadata: metaData});
console.log(sendMe);
fetch('https://ptsv2.com/t/sgsey-1592237741/post', { method: 'POST', body: sendMe })
.then(res => console.log(res)) // expecting a json response
})
fs.createReadStream(path.resolve(__dirname, '../../flaky-tap-log.tap')).pipe(p);

} catch (error) {
core.setFailed(error.message);
}
40 changes: 40 additions & 0 deletions packages/action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

const fetch = require('node-fetch');
const fs = require('fs');
const core = require('@actions/core');
const path = require("path");


try {
// `who-to-greet` input defined in action metadata file

var metaData = {
github: JSON.parse(core.getInput('github')),
os: JSON.parse(core.getInput('os')),
matrix: JSON.parse(core.getInput('matrix'))
};
var fileType = core.getInput('logtype');
var data = fs.readFileSync(path.resolve(__dirname, '../../flaky-tap-log.tap'),"utf8");

var sendMe = JSON.stringify({type: fileType, data: data, metadata: metaData});
console.log("SENDING: \n\n" + sendMe);

fetch('https://ptsv2.com/t/sgsey-1592237741/post', { method: 'POST', body: sendMe }).then(res => console.log("\n\n Received: \n\n" + res))


} catch (error) {
core.setFailed(error.message);
}
Loading