Skip to content

作业提交

作业提交 #127

name: Check loser homework
on:
workflow_call:
inputs:
docker_namespaces:
required: true
type: string
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- '.github/actions/**'
- '.github/workflows/check-loser-homework.yml'
- '**.cmake'
- '**/CMakeLists.txt'
- 'src/群友提交/**'
pull_request:
branches: [ "main" ]
paths:
- '.github/actions/**'
- '.github/workflows/check-loser-homework.yml'
- '**.cmake'
- '**/CMakeLists.txt'
- 'src/群友提交/**'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
need_build_all: ${{ steps.changed-files.outputs.any_changed == 'true' ||
( github.event_name != 'pull_request' && github.event_name != 'push' ) }}
docker_namespaces: ${{ inputs.docker_namespaces == '' && 'mq-b/loser-homework' || inputs.docker_namespaces}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get the changed files that need to build all
id: changed-files
uses: tj-actions/changed-files@v42
with:
separator: ";"
quotepath: false
safe_output: false
files: |
.github/actions/**
.github/workflows/check-loser-homework.yml
**.cmake
**/CMakeLists.txt
src/群友提交/script/**
src/群友提交/**/input.txt
src/群友提交/**/output.txt
check:
needs: prepare
env:
PYTHONIOENCODING: "utf-8"
DOTNET_CLI_FORCE_UTF8_ENCODING: "true"
strategy:
matrix:
include:
- name: GCC-14
os: ubuntu-24.04
cxx_compiler: g++-14
c_compiler: gcc-14
shell: bash
use-ninja: true
- name: Clang-17
os: ubuntu-24.04
cxx_compiler: clang++-17
c_compiler: clang-17
cxx_flags: -stdlib=libc++
container: ghcr.io/${{ needs.prepare.outputs.docker_namespaces }}/clang17
shell: bash
use-ninja: true
- name: MSVC
os: windows-2022
cxx_compiler: cl
c_compiler: cl
shell: pwsh
use-ninja: true
name: check in ${{ matrix.name }}
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.container }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
- uses: actions/checkout@v4
- name: delete unchanged cpp files
if: |
needs.prepare.outputs.need_build_all == 'false'
uses: ./.github/actions/delete-unchanged-cpp-files
with:
path: src/群友提交
shell: ${{ matrix.shell }}
- name: rename evil cjk path
if: ${{ matrix.os == 'windows-2022' }}
run: |
Rename-Item "src/群友提交" -NewName "hw-submit"
$cmakeLists = Get-ChildItem -Recurse -Filter "CMakeLists.txt"
foreach ($file in $cmakeLists) {
$content = Get-Content -Path $file.FullName -encoding UTF8
$newContent = $content -replace "群友提交", "hw-submit"
Set-Content -Path $file.FullName -Value $newContent
}
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
if: ${{ matrix.os == 'windows-2022' }}
- name: Check loser homework
uses: ./.github/actions/check-loser-homework
with:
build-path: ${{github.workspace}}/build
extra-gen-params: >
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
shell: ${{ matrix.shell }}
use-ninja: ${{ matrix.use-ninja }}