Skip to content

Commit

Permalink
更新代码模板与action.
Browse files Browse the repository at this point in the history
  • Loading branch information
Certseeds committed Jul 26, 2020
1 parent 8defd3e commit dd0baf5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
working-directory: ./../
run: |
echo $(pwd)
zip -r script_no_need.zip ./CS203_DSAA_template -x "./.git/*"
zip -r script_no_need.zip ./CS203_DSAA_template -x "*/.git/*"
echo $(pwd)
- name: Create Release
Expand All @@ -55,8 +55,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: 0.0.6.2
release_name: 0.0.6.2
tag_name: 0.0.6.3
release_name: 0.0.6.3
draft: false
prerelease: false

Expand Down
33 changes: 0 additions & 33 deletions script/cpp_template.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
/**
* @Github: https://github.com/{0}/CS203_DSAA_template
* @Organization: SUSTech
* @Author: {1}
* @Date: {2}
* @LastEditors: {1}
* @LICENSE: MIT
*/
/*
MIT License

CS203_DSAA_template

Copyright (C) {3} {1}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <list>
#include <array>
#include <deque>
Expand Down
39 changes: 3 additions & 36 deletions script/cpp_test_template.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
/**
* @Github: https://github.com/{0}/CS203_DSAA_template
* @Organization: SUSTech
* @Author: {1}
* @Date: {2}
* @LastEditors: {1}
* @LICENSE: MIT
*/
/*
MIT License

CS203_DSAA_template

Copyright (C) {3} {1}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef CS203_DSAA_TEST_MACRO
#define CS203_DSAA_TEST_MACRO

#include <tuple>
#include <vector>
#include <iostream>
#include "catch_main.hpp"
#include "lab_{4}_{5}.cpp"
#include "lab_{0}_{1}.cpp"

using std::tie;
using std::cin;
Expand All @@ -49,9 +16,9 @@ using std::vector;
using Catch::Matchers::Equals;
using Catch::Matchers::UnorderedEquals;
using Catch::Matchers::Contains;
const string test_file_path = "./../test/lab_{4}/lab_{4}_{5}_data/";
const string test_file_path = "./../test/lab_{0}/lab_{0}_{1}_data/";

TEST_CASE("test case 1", "[test {4} {5}]") {{
TEST_CASE("test case 1", "[test {0} {1}]") {{
auto output = cal(std::make_tuple(114, 514));
CHECK(output == 628);
CHECK(1 + 2 == 3);
Expand Down
33 changes: 33 additions & 0 deletions script/file_header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @Github: https://github.com/{0}/CS203_DSAA_template
* @Organization: SUSTech
* @Author: {1}
* @Date: {2}
* @LastEditors: {1}
* @LICENSE: MIT
*/
/*
MIT License

CS203_DSAA_template

Copyright (C) {3} {1}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
14 changes: 9 additions & 5 deletions script/file_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

main_code_template: str
test_code_template: str
file_header_template: str
GITHUB_USER: str = "YOUR_GITHUB_NAME" # example: Certseeds
USER: str = "YOUR_USER_NAME" # example: nanoseeds
year: str = time.strftime("%Y", time.localtime())
Expand All @@ -58,10 +59,12 @@ def read_file(file_name: str) -> str:

def fill_file(lab_number: str, problem_order: str) -> None:
with open(source_path.format(lab_number, lab_number, problem_order), mode='a+', encoding="UTF-8") as file:
file.write(main_code_template.format(GITHUB_USER, USER, create_time, year))
print("main finish\n")
file.write(file_header_template.format(GITHUB_USER, USER, create_time, year))
file.write(main_code_template)
print("main finish")
with open(test_path.format(lab_number, lab_number, problem_order), mode='a+', encoding="UTF-8") as file:
file.write(test_code_template.format(GITHUB_USER, USER, create_time, year, lab_number, problem_order))
file.write(file_header_template.format(GITHUB_USER, USER, create_time, year))
file.write(test_code_template.format(lab_number, problem_order))
print('test finish')


Expand All @@ -74,8 +77,9 @@ def try_mkdir(lab_number: str) -> None:

# range in [begin,end)
if __name__ == '__main__':
main_code_template: str = read_file("cpp_template.txt")
test_code_template: str = read_file("cpp_test_template.txt")
file_header_template = read_file("file_header.txt")
main_code_template = read_file("cpp_template.txt")
test_code_template = read_file("cpp_test_template.txt")
labs: List[str] = ['01', '02', '03', '04', '05', '06', '07',
'08', '09', '10', '11', '12', '13', '14', '15']
problem_order: List[chr] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
Expand Down

0 comments on commit dd0baf5

Please sign in to comment.