They were always "deadly opponents," never comrades. Marxism, Communism, and Socialism are in direct opposition to Nazism as a philosophy. Although they referred to themselves as the "National Socialist Workers Party," they actively worked against the interests of the working class. Anyway, after all the other nations in Europe had previously signed treaties and accords with Nazi Germany, USSR was the last significant state in the world to do so (Nazi Germany). Before focusing on extending German hegemony eastward, Hitler desired a calm eastern front until he had conquered western European countries to the point where they posed no danger to German hegemony. Without any fear of conflict or devastation on its western frontiers, the USSR under Stalin desired nothing more than peace to develop socialism within its boundaries. Stalin, the pragmatist who led the Soviet Union, had no doubts that war was coming and that the nation's defenses and armed forces needed time to prepare. The USSR had little choice but to sign the "Non-Aggression Pact" since its effort to build a "alliance" with Britain and France had failed and time was running out. Hitler made the agreement offer to the USSR, which was delighted to accept it and prevent war for at least a few of years.
The "Secret Protocols," an addition to the Non-Aggression Pact between Nazi Germany and the USSR, are a topic of much discussion. These documents were offered as evidence against the USSR during the Nuremberg Trials by surviving Nazi defendants, but they were disregarded as "forgeries." Only during the Cold War era were these documents once more dug out, dusted, and began to be presented as "facts" in anti-Soviet propaganda.
CHEERS!
>> ROR