name: WebScripts38 Tests
on: [push]

jobs:
  build:

    strategy:
      matrix:
        os: ["ubuntu-latest", "windows-latest", "macos-latest"]
    
    name: "Run test on ${{ matrix.os }} with 3.8"
    runs-on: "${{ matrix.os }}"
    
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python 3.8
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
      - name: Test WebScripts with unittest
        run: |
          mkdir WebScripts/hardening
          echo "{}" > WebScripts/hardening/logs_checks.json
          echo "{}" > WebScripts/hardening/uploads_file_integrity.json
          echo "{}" > WebScripts/hardening/webscripts_file_integrity.json
          echo "{}" > WebScripts/hardening/audit.html
          echo "{}" > WebScripts/hardening/audit.txt
          echo "{}" > WebScripts/hardening/audit.json
          python WebScripts/scripts/to_3.8/to_3.8.py
          python -c "from os import replace;from shutil import rmtree,copytree;rmtree('WebScripts');copytree('WebScripts38', 'WebScripts');replace('setup38.py', 'setup.py')"
          python -m unittest discover -s test -p Test*.py -v
          python -c "import json as j,os;f=os.path.join('WebScripts','config','server.json');d=j.load(open(f));d['server']['force_file_permissions']=False;j.dump(d,open(f,'w'))"
          python -c "import os;f=os.path.join('WebScripts','WebScripts.py');d=open(f).read().replace('force_file_permissions = True','force_file_permissions=False');open(f,'w').write(d)"
          python -m WebScripts --test-running --security
          python -m pip install .
          python -m pip install --force-reinstall --install-option "-pabc" --install-option "-d." .
          python setup.py install --admin-password=abc --directory=.
