From f1b25068d19b8fa162c19ab660715d122b04376e Mon Sep 17 00:00:00 2001 From: Viacheslav Kroilov Date: Sat, 30 Nov 2019 11:30:11 +0100 Subject: [PATCH] Optimize CI configuration --- .github/workflows/test_cpp_cmake.yml | 77 ++++++++++++++++++++++++++-- .github/workflows/test_java_make.yml | 47 +++++++++++++++-- .github/workflows/test_python.yml | 41 +++++++++++++-- 3 files changed, 152 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test_cpp_cmake.yml b/.github/workflows/test_cpp_cmake.yml index c3b4c5112..cb403bc4f 100644 --- a/.github/workflows/test_cpp_cmake.yml +++ b/.github/workflows/test_cpp_cmake.yml @@ -1,20 +1,77 @@ name: Test C++ programs -# source: https://github.com/actions/starter-workflows/pull/47 + on: - push - - pull_request + paths-ignore: + - 'epi_judge_java*/**' + - 'epi_judge_python*/**' + - pull_request: + - 'epi_judge_java*/**' + - 'epi_judge_python*/**' env: BUILD_TYPE: Debug jobs: - build: + fast_test: + name: Fast Test + runs-on: ubuntu-latest + + strategy: + matrix: + mode: [stub, solution] + include: + - mode: stub + folder: epi_judge_cpp + - mode: solution + folder: epi_judge_cpp_solutions + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install click + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{runner.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE/${{matrix.folder}} -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + run: cmake --build . --config $BUILD_TYPE -- -j 8 + + - name: Test + shell: bash + run: python epijudge_ci_test_tool.py --build-dir ${{runner.workspace}}/build cpp ${{matrix.mode}} . + + - full_test: + name: Full Test + needs: fast_test runs-on: ${{ matrix.os }} + strategy: - max-parallel: 1 + max-parallel: 2 matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] + os: [windows-latest, macOS-latest] mode: [stub, solution] include: - mode: stub @@ -51,10 +108,20 @@ jobs: run: cmake $GITHUB_WORKSPACE/${{matrix.folder}} -DCMAKE_BUILD_TYPE=$BUILD_TYPE - name: Build + if: runner.os == 'macOS' working-directory: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE -- -j 8 + - name: Build Windows + # Windows doesn't support -j switch + if: runner.os == 'Windows' + working-directory: ${{runner.workspace}}/build + shell: bash + run: cmake --build . --config $BUILD_TYPE -- + - name: Test + # Mac build should be identical to ubuntu, skip to save resources + if: runner.os == 'Windows' shell: bash run: python epijudge_ci_test_tool.py --build-dir ${{runner.workspace}}/build cpp ${{matrix.mode}} . diff --git a/.github/workflows/test_java_make.yml b/.github/workflows/test_java_make.yml index 7c13580d9..096eea12f 100644 --- a/.github/workflows/test_java_make.yml +++ b/.github/workflows/test_java_make.yml @@ -2,14 +2,19 @@ name: Run Java programs on: - push - - pull_request + paths-ignore: + - 'epi_judge_cpp*/**' + - 'epi_judge_python*/**' + - pull_request: + - 'epi_judge_cpp*/**' + - 'epi_judge_python*/**' jobs: - build: - + fast_test: + name: Fast test runs-on: ubuntu-latest + strategy: - max-parallel: 2 matrix: mode: [stub, solution] include: @@ -37,3 +42,37 @@ jobs: run: make -C ${{ matrix.folder }} all - name: Test run: python epijudge_ci_test_tool.py java ${{ matrix.mode }} . + + full_test: + name: Full test + needs: fast_test + runs-on: windows-latest + + strategy: + matrix: + mode: [stub, solution] + include: + - mode: stub + folder: epi_judge_java + - mode: solution + folder: epi_judge_java_solutions + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Set up Java 11 + uses: actions/setup-java@v1 + with: + java-version: '11.0.4' + java-package: jdk + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install click + - name: Compile + run: make -C ${{ matrix.folder }} all + - name: Test + run: python epijudge_ci_test_tool.py java ${{ matrix.mode }} . diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index b43fbc078..5a53999a6 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -2,14 +2,47 @@ name: Run Python programs on: - push - - pull_request + paths-ignore: + - 'epi_judge_cpp*/**' + - 'epi_judge_java*/**' + - pull_request: + - 'epi_judge_cpp*/**' + - 'epi_judge_java*/**' jobs: - build: - + fast_test: + name: Fast test runs-on: ubuntu-latest + + strategy: + max-parallel: 2 + matrix: + python-version: [3.6, 3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install bintrees click + - name: Test stubs + run: | + python epijudge_ci_test_tool.py python stub . + - name: Test solutions + run: | + python epijudge_ci_test_tool.py python solution . + + full_test: + name: Full Test + needs: fast_test + runs-on: windows-latest + strategy: - max-parallel: 4 + max-parallel: 2 matrix: python-version: [3.6, 3.7, 3.8]