Skip to content

Commit

Permalink
Merge pull request #1 from giovanne-oliveira/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
giovanne-oliveira authored May 27, 2022
2 parents 7d01783 + 19c104a commit d2e7319
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 20 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches: [ master ]

permissions: write-all

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -17,7 +19,7 @@ jobs:
id: semver_tagbump
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
WITH_V: false
DEFAULT_BUMP: patch

Expand All @@ -31,7 +33,7 @@ jobs:
id: changelog
uses: loopwerk/tag-changelog@v1
with:
token: ${{ secrets.ACCESS_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create release
uses: actions/create-release@v1
Expand All @@ -43,12 +45,12 @@ jobs:
tag_name: ${{ steps.semver_tagbump.outputs.new_tag}}
body: ${{ steps.changelog.outputs.changes }}
env:
GITHUB_TOKEN: ${{github.token}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Upload artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: builds/ivcli
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/laravel-zero-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches: [ beta ]

permissions: write-all

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -17,7 +19,7 @@ jobs:
id: semver_tagbump
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
WITH_V: false
DEFAULT_BUMP: patch

Expand All @@ -31,7 +33,7 @@ jobs:
id: changelog
uses: loopwerk/tag-changelog@v1
with:
token: ${{ secrets.ACCESS_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create release
uses: actions/create-release@v1
Expand All @@ -43,12 +45,12 @@ jobs:
tag_name: ${{ steps.semver_tagbump.outputs.new_tag}}
body: ${{ steps.changelog.outputs.changes }}
env:
GITHUB_TOKEN: ${{github.token}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Upload artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: builds/ivcli
Expand Down
50 changes: 40 additions & 10 deletions app/Commands/CloseInterviewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class CloseInterviewCommand extends Command

private $backupCandidateFiles = true;

private $hireRecommendation;

private $indicatedPosition;

private $error;

private $mysqldumpPath = '/usr/bin/mysqldump';
Expand Down Expand Up @@ -96,7 +100,11 @@ public function handle()

$this->completionSteps = $this->question('How many steps the candidate completed before the end of the test?', 0);

$this->indicatedPosition = $this->choice('Which position did the candidate indicate?', ['junior', 'plain', 'senior']);
$this->hireRecommendation = $this->choice('What\'s your recommendation for this candidate?', ['strong no hire', 'not recommended', 'recommended', 'strong hire']);

if($this->hireRecommendation > 1){
$this->indicatedPosition = $this->choice('What\'s the indicated position for this candidate?', ['junior', 'mid', 'senior', 'lead', 'other']);
}


$this->info('Closing interview environment for ' . $this->candidateName);
Expand Down Expand Up @@ -268,7 +276,15 @@ private function closeCodeServerSession()
// Set the interview ID
$this->interviewId = $meta[0]->id;

$process = BackgroundProcess::createFromPID($meta[0]->pid);
// Get list of all PIDs from /usr/lib/code-server process

$cmdOutput = explode("\n", shell_exec("ps aux | grep /usr/lib/code-server | awk '{print $2}'"));
if (!is_array($cmdOutput)) {
// TODO: soft-execution adaptations here
$this->error('Error while fetching PIDs from Code-server process');
return false;
}

/*
// TODO: This was disabled until I found a way to return if the process was already killed
// or insert a command flag to allow the "soft-execution" of this script
Expand All @@ -278,13 +294,19 @@ private function closeCodeServerSession()
$this->error('The session is already closed or process not found.');
return false;
}*/

if ($process->stop()) {
DB::table('code_server_instances')->where('candidate_name', $candidateName)->update(['status' => 0]);
return true;
}else{
$this->error('Error while closing code-server session.');
return false;
foreach ($cmdOutput as $pid) {
if ($pid == '') {
continue;
}
$pid = trim($pid);
$process = BackgroundProcess::createFromPID($pid);
if ($process->stop()) {
DB::table('code_server_instances')->where('candidate_name', $candidateName)->update(['status' => 0]);
return true;
} else {
$this->error('Error while closing code-server session.');
return false;
}
}
}

Expand Down Expand Up @@ -313,7 +335,15 @@ private function postActionHooks()
// Here we can insert some code to run after the candidate has been removed

// Update the candidate's status and recommendations


// TODO: Calculate the general score based on how many steps the candidate completed and how much time it took.
// For now, we'll just set it to 0.
$score = 0;
DB::update(
'UPDATE code_server_instances SET hire_recommendation_level = ?, position_level_recommendation = ?, general_score = ? WHERE id = ?',
[$this->hireRecommendation, $this->indicatedPosition, $score, $this->interviewId]
);


// Write the end time for the interview
// TODO: Write a better query for this
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/CreateInterviewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ private function populateCandidateFolder()
$this->databaseInfo['password'],
$this->databaseInfo['database'],
$this->databaseInfo['port'],
env('PUBLIC_URL'),
env('PHPMYADMIN_URL').$this->candidateName,
env('PUBLIC_URL').$this->candidateName,
env('PHPMYADMIN_URL'),
];

$writeFileResponse = File::put(
Expand Down
32 changes: 32 additions & 0 deletions database/migrations/2022_05_27_144023_add_candidate_grade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddCandidateGrade extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('code_server_instances', function (Blueprint $table) {
$table->string('hire_recommendation_level')->nullable(); // Strong no hire, no hire, hire, strong hire
$table->string('position_level_recommendation')->nullable(); // Junior, Plain, Senior, Tech Lead
$table->string('general_score')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

0 comments on commit d2e7319

Please sign in to comment.