Update README.md #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run MATLAB ComputeTrueSol | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
if: "contains(github.event.head_commit.message, '[run-ComputeTrueSol]')" | |
strategy: | |
matrix: | |
type: ['Merton', 'Kou'] | |
Nx: [256, 512, 1024] | |
mesh_ratio: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Set up MATLAB | |
uses: matlab-actions/setup-matlab@v1 | |
- name: Run MATLAB Function | |
id: run-matlab-function | |
uses: matlab-actions/run-command@v1.2.0 | |
with: | |
command: | | |
% Get the root directory path | |
root = pwd(); | |
temp_root_path = fullfile(getenv('GITHUB_WORKSPACE'), 'temp_root.txt'); | |
fid = fopen(temp_root_path, 'w'); | |
fprintf(fid, '%s', root); | |
fclose(fid); | |
% Change to tests folder | |
cd tests | |
% Add MATLAB functions to path | |
currentFolder = fileparts(which('ComputeTrueSol')); | |
methodsFolder = fullfile(currentFolder, '..', 'methods'); | |
addpath(methodsFolder); | |
% Define problem parameters | |
problem_paras.T = 1; | |
problem_paras.K = 1; | |
problem_paras.sig1 = 0.8; | |
problem_paras.sig2 = 0.3; | |
problem_paras.r1 = 0.05; | |
problem_paras.r2 = 0.05; | |
problem_paras.d1 = 0.025; | |
problem_paras.d2 = 0.025; | |
problem_paras.lam1 = 0.25; | |
problem_paras.lam2 = 0.2; | |
problem_paras.A = [-2 2; 3 -3]; | |
problem_paras.type = '${{ matrix.type }}'; | |
% Run ComputeTrueSol function | |
Nx = ${{ matrix.Nx }}; | |
mesh_ratio = ${{ matrix.mesh_ratio }}; | |
[full_path, filename] = ComputeTrueSol(Nx, mesh_ratio, problem_paras); | |
temp_output_path = fullfile(getenv('GITHUB_WORKSPACE'), 'temp_output.txt'); | |
fid = fopen(temp_output_path, 'w'); | |
fprintf(fid, 'full_path: %s\n', full_path); | |
fprintf(fid, 'filename: %s\n', filename); | |
fclose(fid); | |
- name: Read output from temp files | |
run: | | |
echo "Content of temp_output.txt:" | |
cat temp_output.txt | |
echo "full_path=$(grep -oP 'full_path: \K.*' temp_output.txt)" >> $GITHUB_ENV | |
echo "root_path=$(cat temp_root.txt)" >> $GITHUB_ENV | |
echo "filename=$(grep -oP 'filename: \K.*' temp_output.txt)" >> $GITHUB_ENV | |
- name: Debug environment variables | |
run: | | |
echo "full_path: ${{ env.full_path }}" | |
echo "filename: ${{ env.filename }}" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{ env.filename }} | |
path: ${{ env.root_path }}/data_TrueSol/${{ env.filename }} |