Commit 7eb969f0 authored by Giuseppe Carboni's avatar Giuseppe Carboni
Browse files

Merge branch 'fix-issue-901' of https://github.com/discos/discos into fix-issue-885

parents a091596d f63307b1
Loading
Loading
Loading
Loading
+53 −0
Original line number Original line Diff line number Diff line
#!/usr/bin/env python
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseDownload
import os
import io

TOKEN_FILE = 'token.json'
VM_FILE_PATH = '/home/runner/discos_manager.ova'
ARCHIVE_FILE_PATH = '/home/runner/vagrant.tar.gz'
SCOPES = ['https://www.googleapis.com/auth/drive.readonly']

# Create the token file from the GH Secret
with open(TOKEN_FILE, 'w') as tokenfile:
    tokenfile.write(os.environ.get('GOOGLE_DRIVE_TOKEN'))

# Authenticate with the token and eventually update it
creds = Credentials.from_authorized_user_file(TOKEN_FILE, SCOPES)
if creds.expired and creds.refresh_token:
    creds.refresh(Request())

# Download the VM
creds = Credentials.from_authorized_user_file(TOKEN_FILE, SCOPES)
if creds.expired and creds.refresh_token:
    creds.refresh(Request())

service = build('drive', 'v3', credentials=creds)

downloader = MediaIoBaseDownload(
    io.FileIO(ARCHIVE_FILE_PATH, 'wb'),
    service.files().get_media(
        fileId=os.environ.get('PROVISIONED_ARCHIVE_GDRIVE_ID')
    )
)
done = False
while not done:
    _, done = downloader.next_chunk()

downloader = MediaIoBaseDownload(
    io.FileIO(VM_FILE_PATH, 'wb'),
    service.files().get_media(
        fileId=os.environ.get('PROVISIONED_VM_GDRIVE_ID'),
    ),
    chunksize=5*1024*1024
)
done = False
while not done:
    _, done = downloader.next_chunk()

# Finally update the token file
with open(TOKEN_FILE, 'w') as tokenfile:
    tokenfile.write(creds.to_json())
+4 −0
Original line number Original line Diff line number Diff line
google-auth
google-auth-oauthlib
google-auth-httplib2
google-api-python-client
+70 −0
Original line number Original line Diff line number Diff line
name: DISCOS deployment and build

on:
  push:
  workflow_dispatch:

jobs:
  deploy-discos:
    env:
      REPOSITORY_TOKEN: "${{ secrets.DEPENDENCIES_TOKEN }}"
      GH_TOKEN: "${{ secrets.GH_WORKFLOWS_TOKEN }}"
      GOOGLE_DRIVE_TOKEN: "${{ secrets.GOOGLE_DRIVE_TOKEN }}"
      PROVISIONED_VM_GDRIVE_ID: "${{ secrets.PROVISIONED_VM_GDRIVE_ID }}"
      PROVISIONED_ARCHIVE_GDRIVE_ID: "${{ secrets.PROVISIONED_ARCHIVE_GDRIVE_ID }}"
    strategy:
      fail-fast: false
      matrix:
        station: ['SRT', 'Medicina', 'Noto']
    runs-on: ubuntu-22.04
    steps:
      - name: Free up space
        uses: jlumbroso/free-disk-space@main
        with:
          tool-cache: true
      - name: Install Vagrant
        run: |
          wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
          echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
          sudo apt update && sudo apt install vagrant
      - name: Install VirtualBox
        run: |
          wget https://download.virtualbox.org/virtualbox/7.0.14/virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb
          sudo apt install ./virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb
      - name: Clone the repository
        uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3'
          check-latest: true
      - name: Download the provisioned virtual machine from Google Drive
        run: |
          pip install -r .github/utils/gdrive_requirements.txt
          python .github/utils/download_from_gdrive.py
          gh secret set GOOGLE_DRIVE_TOKEN --org discos --visibility selected --repos discos,deployment < token.json
      - name: Install the virtual machine
        run: |
          vboxmanage import discos_manager.ova --vsys 0 --options keepallmacs
          rm discos_manager.ova
          tar -xzvf vagrant.tar.gz
        working-directory: /home/runner
      - name: Add the virtual machine to Vagrant
        run: |
          sed -i "s/$(cat id)/$(vboxmanage list vms | grep 'discos_manager' | grep -oP '(?<=\{)[0-9a-fA-F-]+(?=\})')/" action_provision
          sed -i "s/$(cat id)/$(vboxmanage list vms | grep 'discos_manager' | grep -oP '(?<=\{)[0-9a-fA-F-]+(?=\})')/" id
        working-directory: /home/runner/.deployment/.vagrant/machines/manager/virtualbox/
      - name: Clone the deployment repository
        uses: actions/checkout@v4
        with:
          repository: 'discos/deployment'
      - name: Install deployment package and dependencies
        run: |
          python -m pip install -r requirements.txt
          pip install .
      - name: Deploy DISCOS
        run: |
          discos-deploy manager:development --deploy-only -s ${{ matrix.station }} -b ${{ github.ref_name }}
      - name: Shutdown the virtual machine
        run: |
          discos-vms stop
+3 −0
Original line number Original line Diff line number Diff line
@@ -144,6 +144,7 @@ void USDImpl::initialize() throw (ACSErr::ACSbaseExImpl)
            _SET_LDEF(acc,   "USDImpl::initialize()");
            _SET_LDEF(acc,   "USDImpl::initialize()");
            _SET_LDEF(uBits, "USDImpl::initialize()");
            _SET_LDEF(uBits, "USDImpl::initialize()");
        }
        }
        _GET_PROP(status,m_status,"usdImpl::initialize()")
    }
    }
    catch (ASErrors::ASErrorsEx& ex)
    catch (ASErrors::ASErrorsEx& ex)
    {
    {
@@ -324,6 +325,8 @@ void USDImpl::reset() throw (CORBA::SystemException,ASErrors::ASErrorsEx)
        //_SET_CDB(calibrate, m_calibrate, "::USDImpl::reset()")
        //_SET_CDB(calibrate, m_calibrate, "::USDImpl::reset()")
        action(RESET);
        action(RESET);


        CIRATools::Wait(0, 200000); // 0.2 secs, guard time to wait after a reset command

        //* restore defaults *//
        //* restore defaults *//
        _SET_LDEF(delay, "USDImpl::reset()");
        _SET_LDEF(delay, "USDImpl::reset()");
        _SET_LDEF(Fmax,  "USDImpl::reset()");
        _SET_LDEF(Fmax,  "USDImpl::reset()");
+1 −1
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ using namespace Schedule;
#define BACKENDLIST "BACKENDLIST:"
#define BACKENDLIST "BACKENDLIST:"
#define MODE "MODE:"
#define MODE "MODE:"
#define SCANTAG "SCANTAG:"
#define SCANTAG "SCANTAG:"
#define ELEVATIONLIMITS "ELEVATIONLIMITS"
#define ELEVATIONLIMITS "ELEVATIONLIMITS:"
#define INITPROC "INITPROC:"
#define INITPROC "INITPROC:"
#define SCAN_START "SC:"
#define SCAN_START "SC:"


Loading