Skip to content

Commit

Permalink
ops(hermes): setup testing environment for ci pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
WarriorsSami committed Jun 22, 2024
1 parent 602918b commit 63676f2
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 44 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/hermes-tests-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Hermes - Build and Test Tests Service

on:
push:
paths:
- "hermes-tests/**"
- ".github/workflows/hermes-tests-ci.yaml"

pull_request:
paths:
- "hermes-tests/**"
- ".github/workflows/hermes-tests-ci.yaml"

env:
HERMES_CONFIG: ${{ secrets.HERMES_CONFIG }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@v1
with:
sdk: 2.19.2

- name: Get dependencies
run: |
cd hermes-tests
dart pub get
- name: Format code
run: dart format --set-exit-if-changed .

- name: Analyze code
run: dart analyze

- name: Test
run: dart test
1 change: 1 addition & 0 deletions hermes-tests/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode/
.idea/
.dart_tool/
.fvm*
test/
temp/test/
*.md
Expand Down
8 changes: 6 additions & 2 deletions hermes-tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
.dart_tool/
.idea/
.vscode/
temp/
#temp/
logs/
config.json
.env
.env

# FVM Version Cache
.fvm/
.fvmrc
2 changes: 1 addition & 1 deletion hermes-tests/bin/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:hermes_tests/domain/core/file_log_output.dart';
import 'package:logger/logger.dart';

Future<void> main(List<String> arguments) async {
final config = Config.fromJsonFile('config.json');
final config = Config.fromEnv('HERMES_CONFIG');
final serverConfig = ServerConfig.fromJson(config.dev);

final logger = Logger(
Expand Down
Binary file added hermes-tests/temp/test/archived/sum/1-invalid.tar.gz
Binary file not shown.
Binary file added hermes-tests/temp/test/archived/sum/1-oversize.zip
Binary file not shown.
Binary file added hermes-tests/temp/test/archived/sum/1-valid.zip
Binary file not shown.
Binary file added hermes-tests/temp/test/archived/sum/1.zip
Binary file not shown.
Binary file added hermes-tests/temp/test/archived/sum/4.zip
Binary file not shown.
1 change: 1 addition & 0 deletions hermes-tests/temp/test/unarchived/sum/2/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 1
1 change: 1 addition & 0 deletions hermes-tests/temp/test/unarchived/sum/2/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
1 change: 1 addition & 0 deletions hermes-tests/temp/test/unarchived/sum/6/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 1
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ void main() {
'Then the uploaded test is accessible from the remote firebase cloud storage',
() async {
// Arrange
final String testPath = 'temp/test/archived/marsx/1-valid.zip';
final String testPath = 'temp/test/archived/sum/1-valid.zip';
final Metadata testMetadata = Metadata()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '10'
..testSize = File(testPath).lengthSync();

Expand Down Expand Up @@ -100,7 +100,7 @@ void main() {
() async {
// Arrange
final request = DownloadRequest()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '9';

// Act
Expand Down Expand Up @@ -133,9 +133,9 @@ void main() {
'Then the test is deleted from the remote firebase cloud storage',
() async {
// Arrange
final String testPath = 'temp/test/archived/marsx/1-valid.zip';
final String testPath = 'temp/test/archived/sum/1-valid.zip';
final Metadata testMetadata = Metadata()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '10'
..testSize = File(testPath).lengthSync();

Expand All @@ -154,6 +154,14 @@ void main() {
// Assert
expect(response.status.code, StatusCode.Ok);

final String localTestArchivePath =
'${testConfig.tempLocalArchivedTestFolder}/${testMetadata.problemId}/${testMetadata.testId}.zip';
final String localTestPath =
'${testConfig.tempLocalUnarchivedTestFolder}/${testMetadata.problemId}/${testMetadata.testId}';

FileManager.disposeLocalFile(localTestArchivePath);
FileManager.disposeLocalDirectory(localTestPath);

client.close();
});

Expand All @@ -163,7 +171,7 @@ void main() {
'Then the download link is successfully retrieved', () async {
// Arrange
final request = GetDownloadLinkForTestRequest()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '9';

// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() {
group('Download Test UseCase Unit Tests', () {
setUpAll(() {
testConfig = ServerConfig.fromJson(
Config.fromJsonFile('config.json').test,
Config.fromEnv('HERMES_CONFIG').test,
);
mockTestRepository = MockTestRepository();
final logger = Logger(
Expand Down Expand Up @@ -52,7 +52,7 @@ void main() {
() async {
// Arrange
final TestMetadata requestTestMetadata = TestMetadata.testToDownload(
problemId: 'marsx',
problemId: 'sum',
testId: '2',
fromDir: testConfig.remoteUnarchivedTestFolder,
toDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down Expand Up @@ -84,7 +84,7 @@ void main() {
'Then localTestNotFound storage failure is returned', () async {
// Arrange
final TestMetadata requestTestMetadata = TestMetadata.testToDownload(
problemId: 'marsx',
problemId: 'sum',
testId: '6',
fromDir: testConfig.remoteUnarchivedTestFolder,
toDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down Expand Up @@ -122,7 +122,7 @@ void main() {
'Then unexpected storage failure is returned', () async {
// Arrange
final TestMetadata requestTestMetadata = TestMetadata.testToDownload(
problemId: 'marsx',
problemId: 'sum',
testId: '5',
fromDir: testConfig.remoteUnarchivedTestFolder,
toDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down Expand Up @@ -163,7 +163,7 @@ void main() {
'Then unexpected storage failure is returned', () async {
// Arrange
final TestMetadata requestTestMetadata = TestMetadata.testToUpload(
problemId: 'marsx',
problemId: 'sum',
testId: '5',
fromDir: testConfig.remoteUnarchivedTestFolder,
toDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {
group('Encode Test UseCase Unit Tests', () {
setUpAll(() {
testConfig = ServerConfig.fromJson(
Config.fromJsonFile('config.json').test,
Config.fromEnv('HERMES_CONFIG').test,
);
final logger = Logger(
output: FileLogOutput(
Expand All @@ -42,7 +42,7 @@ void main() {
'Then metadata for corresponding archived test is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToEncode(
problemId: 'marsx',
problemId: 'sum',
testId: '2',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down Expand Up @@ -77,7 +77,7 @@ void main() {
'Then metadata for corresponding archived test is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToEncode(
problemId: 'marsx',
problemId: 'sum',
testId: '1',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalUnarchivedTestFolder,
Expand All @@ -103,7 +103,7 @@ void main() {
'Then localTestNotFound storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToEncode(
problemId: 'marsx',
problemId: 'sum',
testId: '3',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down Expand Up @@ -135,7 +135,7 @@ void main() {
'Then invalidLocalTestFormat storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToEncode(
problemId: 'marsx',
problemId: 'sum',
testId: '6',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down Expand Up @@ -167,7 +167,7 @@ void main() {
'Then unexpected storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToDecode(
problemId: 'marsx',
problemId: 'sum',
testId: '6',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalUnarchivedTestFolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {
group('Fragment Test UseCase Unit Tests', () {
setUpAll(() {
testConfig = ServerConfig.fromJson(
Config.fromJsonFile('config.json').test,
Config.fromEnv('HERMES_CONFIG').test,
);
final logger = Logger(
output: FileLogOutput(
Expand All @@ -42,7 +42,7 @@ void main() {
'Then a stream of chunks is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToFragment(
problemId: 'marsx',
problemId: 'sum',
testId: '1',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalArchivedTestFolder,
Expand Down Expand Up @@ -78,7 +78,7 @@ void main() {
'Then localTestNotFound storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToFragment(
problemId: 'marsx',
problemId: 'sum',
testId: '7',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalArchivedTestFolder,
Expand Down Expand Up @@ -108,7 +108,7 @@ void main() {
'Then invalidLocalTestFormat storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToFragment(
problemId: 'marsx',
problemId: 'sum',
testId: '4',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalArchivedTestFolder,
Expand Down Expand Up @@ -138,7 +138,7 @@ void main() {
'Then unexpected storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToUpload(
problemId: 'marsx',
problemId: 'sum',
testId: '4',
fromDir: testConfig.tempLocalUnarchivedTestFolder,
toDir: testConfig.remoteUnarchivedTestFolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {
group('Decode Test UseCase Unit Tests', () {
setUpAll(() {
testConfig = ServerConfig.fromJson(
Config.fromJsonFile('config.json').test,
Config.fromEnv('HERMES_CONFIG').test,
);
final logger = Logger(
output: FileLogOutput(
Expand All @@ -43,7 +43,7 @@ void main() {
() async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToDecode(
problemId: 'marsx',
problemId: 'sum',
testId: '1',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalArchivedTestFolder,
Expand Down Expand Up @@ -86,7 +86,7 @@ void main() {
'Then localTestNotFound storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToDecode(
problemId: 'marsx',
problemId: 'sum',
testId: '3',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalArchivedTestFolder,
Expand Down Expand Up @@ -118,7 +118,7 @@ void main() {
'Then invalidLocalTestFormat storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToDecode(
problemId: 'marsx',
problemId: 'sum',
testId: '4',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalArchivedTestFolder,
Expand Down Expand Up @@ -150,7 +150,7 @@ void main() {
'Then unexpected storage failure is returned', () async {
// Arrange
final TestMetadata testMetadata = TestMetadata.testToEncode(
problemId: 'marsx',
problemId: 'sum',
testId: '4',
archiveTypeExtension: testConfig.archiveTypeExtension,
fromDir: testConfig.tempLocalArchivedTestFolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void main() {
group('Defragment Test UseCase Unit Tests', () {
setUpAll(() async {
testConfig = ServerConfig.fromJson(
Config.fromJsonFile('config.json').test,
Config.fromEnv('HERMES_CONFIG').test,
);
final logger = Logger(
output: FileLogOutput(
Expand All @@ -44,11 +44,11 @@ void main() {
'Then the test is successfully written on disk '
'and associated metadata is returned', () async {
// Arrange
final String inputPath = 'temp/test/archived/marsx/1-valid.zip';
final String inputPath = 'temp/test/archived/sum/1-valid.zip';
final int testSize = File(inputPath).lengthSync();

final Metadata metadata = Metadata()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '2'
..testSize = testSize;

Expand Down Expand Up @@ -89,11 +89,11 @@ void main() {
'When defragment test use case is called, '
'Then invalidLocalTestFormat storage failure is returned', () async {
// Arrange
final String inputPath = 'temp/test/archived/marsx/1-invalid.tar.xz';
final String inputPath = 'temp/test/archived/sum/1-invalid.tar.gz';
final int testSize = File(inputPath).lengthSync();

final Metadata metadata = Metadata()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '2'
..testSize = testSize;

Expand Down Expand Up @@ -134,11 +134,11 @@ void main() {
'When defragment test use case is called, '
'Then testSizeLimitExceeded storage failure is returned', () async {
// Arrange
final String inputPath = 'temp/test/archived/marsx/1-oversize.zip';
final String inputPath = 'temp/test/archived/sum/1-oversize.zip';
final int testSize = File(inputPath).lengthSync();

final Metadata metadata = Metadata()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '2'
..testSize = testSize;

Expand Down Expand Up @@ -179,11 +179,11 @@ void main() {
'When defragment test use case is called, '
'Then unexpected storage failure is returned', () async {
// Arrange
final String inputPath = 'temp/test/archived/marsx/1-oversize.zip';
final String inputPath = 'temp/test/archived/sum/1-oversize.zip';
final int testSize = File(inputPath).lengthSync();

final Metadata metadata = Metadata()
..problemId = 'marsx'
..problemId = 'sum'
..testId = '2'
..testSize = testSize;

Expand Down
Loading

0 comments on commit 63676f2

Please sign in to comment.