diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10f312b..78f4de3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,28 +15,26 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - uses: actions/checkout@v2 - - - name: Move to python workspace - run: cd src - - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.11' - architecture: 'x64' - name: Install dependencies - run: pip install poetry + working-directory: ./src + run: | + pip install poetry + poetry install - - name: Setup poetry project - run: poetry install + - name: Set up Docker Compose + working-directory: ./src + run: docker-compose up -d - name: Run tests (inside Docker) + working-directory: ./src run: | - pytest src/test --junitxml=pytest_report.xml - continue-on-error: true - + docker-compose exec fastapi_server pytest /code/test/ --junitxml=/code/pytest_report.xml + docker cp ${CONTAINER_ID}:/code/pytest_report.xml pytest_report.xml - name: Install Node.js and xml2js uses: actions/setup-node@v3 @@ -44,11 +42,11 @@ jobs: node-version: '16' - name: Install xml2js - run: | - npm install xml2js + working-directory: ./src + run: npm install xml2js - name: Report test results - if: failure() + working-directory: ./src uses: actions/github-script@v6 with: script: | @@ -56,7 +54,7 @@ jobs: const xml2js = require('xml2js'); const core = require('@actions/core'); const parser = new xml2js.Parser(); - const xml = fs.readFileSync('src/pytest_report.xml', 'utf8'); + const xml = fs.readFileSync('pytest_report.xml', 'utf8'); parser.parseString(xml, (err, result) => { if (err) { core.setFailed('Failed to parse XML');